當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript express.urlencoded函數代碼示例

本文整理匯總了TypeScript中express.urlencoded函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript urlencoded函數的具體用法?TypeScript urlencoded怎麽用?TypeScript urlencoded使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了urlencoded函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

    res.status(200).send('ok');
});
var server = app.listen(3000, function () {
    var port = server.address().port;
    console.log('Example app listening at port %s', port);
});


// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(app.router);

import stylus = require('stylus');
app.use(stylus.middleware(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));

// development only
if ('development' == app.get('env')) {
    app.use(express.errorHandler());
}

app.get('/', routes.index);
app.get('/about', routes.about);
app.get('/contact', routes.contact);
開發者ID:nrouelle,項目名稱:KeepItUp,代碼行數:31,代碼來源:server.ts

示例2: function

} else {
    app.basePath = "/var/www/letterapp";
}

var allowCrossDomain = function(req, res, next) {
    res.header('Access-Control-Allow-Origin', 'http://localhost:9000');
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
    res.header('Access-Control-Allow-Headers', 'Content-Type');

    next();
};

// all environments
app.use(express.limit('70mb'));
app.use(express.json({limit: '70mb'}));
app.use(express.urlencoded({limit: '70mb'}));
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.set('view options', {pretty: config.isProd()});
app.locals.pretty = !config.isProd();
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
if (!config.isProd()) {
    app.use(allowCrossDomain);
}
開發者ID:arein,項目名稱:Mils-Server,代碼行數:31,代碼來源:app.ts

示例3: next

        next(err);
    });

    app.get('/', (req, res) => {
        res.send('hello world');
    });

    // Accept json app-wide or on one endpoint.
    app.use(express.json({ limit: "200kb" }));
    app.post('/echo', express.json(), (req, res) => {
        res.json(req.body);
    });

    // Accept urlencoded app-wide or on one endpoint.
    app.use(express.urlencoded({
        extended: false,
        parameterLimit: 16
    }));
    app.post('/search', express.urlencoded(), (req, res) => {
        res.json(Object.keys(req.body));
    });

    const router = express.Router({ caseSensitive: true, mergeParams: true, strict: true });

    const pathStr = 'test';
    const pathRE: RegExp = /test/;
    const path = true ? pathStr : pathRE;

    router.get(path);
    router.put(path);
    router.post(path);
    router.delete(path);
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:32,代碼來源:express-tests.ts

示例4: express

import cors from 'cors';
import helmet from 'helmet';
import filter from 'content-filter';

import {applyRoutes} from './app/routes';

mongoose.connect('mongodb://mongodb/budget', {
    promiseLibrary: global.Promise,
    useNewUrlParser: true
});

const app = express();

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({extended: false}));

app.set('x-powered-by', false);
app.use(cors());
app.use(helmet());
app.use(filter());

applyRoutes(app);

// catch 404 and forward to error handler
app.use((req: express.Request, res: express.Response, next: express.NextFunction) => {
    next(createError(404));
});

// error handler
app.use((err: {
開發者ID:Antyneskul,項目名稱:homeBudgetApi,代碼行數:31,代碼來源:app.ts


注:本文中的express.urlencoded函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。