当前位置: 首页>>代码示例>>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;未经允许,请勿转载。