From 9f1f16c8e347f2bb2c0c6ab1b71c1a683a413a90 Mon Sep 17 00:00:00 2001 From: BoHong Li Date: Wed, 12 Apr 2017 05:31:22 +0800 Subject: [PATCH] refactor(app.js): Extract urlencodedParser to utils module --- app.js | 7 +------ lib/web/utils.js | 9 +++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 lib/web/utils.js diff --git a/app.js b/app.js index c18e01f..b00f37b 100644 --- a/app.js +++ b/app.js @@ -7,6 +7,7 @@ var passport = require('passport') var methodOverride = require('method-override') var cookieParser = require('cookie-parser') var bodyParser = require('body-parser') +const {urlencodedParser} = require('./lib/web/utils') var compression = require('compression') var session = require('express-session') var SequelizeStore = require('connect-session-sequelize')(session.Store) @@ -98,12 +99,6 @@ realtime.io = io // methodOverride app.use(methodOverride('_method')) -// create application/x-www-form-urlencoded parser -var urlencodedParser = bodyParser.urlencoded({ - extended: false, - limit: 1024 * 1024 * 10 // 10 mb -}) - // session store var sessionStore = new SequelizeStore({ db: models.sequelize diff --git a/lib/web/utils.js b/lib/web/utils.js new file mode 100644 index 0000000..c901652 --- /dev/null +++ b/lib/web/utils.js @@ -0,0 +1,9 @@ +'use strict' + +const bodyParser = require('body-parser') + +// create application/x-www-form-urlencoded parser +exports.urlencodedParser = bodyParser.urlencoded({ + extended: false, + limit: 1024 * 1024 * 10 // 10 mb +})