本文整理汇总了TypeScript中body-parser.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: init
static init(application:Object, exp:Object):void
{
var _files = (process.env.NODE_ENV === 'production') ? '/client/dist/' : '/client/__tmp/';
var _root = process.cwd();
application.use(exp.static(_root + _files));
application.use(bodyParser());
application.use(morgan('dev'));
application.use(contentLength.validateMax({max: 999}));
application.use(helmet());
}
示例2: createServer
function createServer(spec: spec) {
if (server) {
server.destroy();
}
app = express();
let protocol = "http";
if (spec.server.certificatePath && spec.server.keyPath) {
const options = {
key: fs.readFileSync(spec.server.keyPath),
cert: fs.readFileSync(spec.server.certificatePath),
requestCert: false,
rejectUnauthorized: false
};
server = https.createServer(options, app);
protocol = "https";
} else {
server = http.createServer(app);
}
enableDestroy(server);
app.use(bodyParser());
app.use(bodyParser.urlencoded({ extended: true }));
if (spec.server.staticFolder) {
app.use(express.static(spec.server.staticFolder));
}
server.listen(spec.server.port, () => {
console.log(`http://localhost:${spec.server.port}`);
});
updateRoutes(app, spec.endpoints);
return {
protocol,
server,
app
};
}
示例3: require
// Connect/Express middleware
var body_parser = require('body-parser');
var compression = require('compression');
var errorhandler = require('errorhandler');
var method_override = require('method-override');
var app = express();
// Settings
app.set('views', __dirname + '/views');
app.set('view engine', 'vash');
// Configuration
app.use(compression());
app.use(body_parser());
app.use(method_override());
// Routes
routes.setupRoutes(app);
// Catch All
app.use(express.static(__dirname + '/public'));
app.use(function (req: express.Request, res: express.Response, next) {
res.status(404);
if (req.accepts('html')) {
res.render('_shared/404');
return;
}
if (req.accepts('json')) {
res.send({ error: 'Not found' });
示例4: require
import fs = require('fs');
import http = require('http');
import express = require('express');
var engines = require('consolidate');
var methodOverride = require('method-override');
var path = require('path');
var bodyParser:any = require('body-parser');
import BasicAuth = require('./BasicAuth');
var app = express();
app.use(BasicAuth.authenticator);
app.set('port', process.env.PORT || 8000);
app.set('views', __dirname + '/../app');
app.engine('html', engines.ect);
app.use(bodyParser());
app.use(methodOverride());
app.use(express.static(path.join(__dirname, '../app')));
app.get('/', function(req, res){
res.render('index.html');
});
app.get('/partials/:name', function (req, res) {
var name = req.params.name;
res.render('partials/' + name + '.html');
});
// redirect all others to the index (HTML5 history)
app.get('*', function(req, res){
res.render('index.html');
示例5: require
var routes = require('./routes/index');
alert_log(routes, 'routes');
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
alert_log({}, 'Jade Start.');
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(bodyParser({limit: '50mb'}));
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
app.use(cookieParser());
var mongoose = require('mongoose');
alert_log(mongoose, 'mongoose');
var MongoStore = require('connect-mongo')(session);
alert_log(MongoStore, 'MongoStore');
var options = {server: {socketOptions: {connectTimeoutMS: 1000000}}};
var connection = "mongodb://" + config.dbuser + ":" + config.dbpassword + "@" + config.dbaddress + "/" + config.dbname;
mongoose.connect(connection, options);