add express-validator, add body parser middleware, support some more errors in error handler middleware

This commit is contained in:
Matteo Pagliazzi
2015-11-08 22:48:31 +01:00
parent 87f50ff2b9
commit 7dd6eb76c9
4 changed files with 54 additions and 3 deletions

View File

@@ -1,8 +1,17 @@
// This module is only used to attach middlewares to the express app
import errorHandler from './errorHandler';
import bodyParser from 'body-parser';
export default function attachMiddlewares (app) {
// Parse query parameters and json bodies
// TODO handle errors
app.use(bodyParser.urlencoded(
extended: true, // Uses 'qs' library as old connect middleware
}));
app.use(bodyParser.json());
// Error handler middleware, define as the last one
app.use(errorHandler);
}