Configure the maximum request body size

Related to #28.
This commit is contained in:
Zalmoxisus 2016-11-09 12:54:42 +02:00
parent 8b3a251e20
commit ee32bd52a6
2 changed files with 4 additions and 2 deletions

View File

@ -18,6 +18,7 @@ module.exports = function getOptions(argv) {
passphrase: argv.passphrase || process.env.npm_package_remotedev_passphrase || null
},
dbOptions: dbOptions,
maxRequestBody: argv.passphrase || '16mb',
logLevel: argv.logLevel || 3
};
}

View File

@ -8,6 +8,7 @@ module.exports.run = function(worker) {
var httpServer = worker.httpServer;
var scServer = worker.scServer;
var store = createStore(worker.options);
var limit = worker.options.maxRequestBody;
httpServer.on('request', app);
@ -19,8 +20,8 @@ module.exports.run = function(worker) {
});
app.use(cors({ methods: 'POST' }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json({ limit: limit }));
app.use(bodyParser.urlencoded({ limit: limit, extended: false }));
app.post('/', function(req, res) {
if (!req.body) return res.status(404).end();
switch(req.body.op) {