Ver código fonte

Added body parser

Fela Maslen 7 anos atrás
pai
commit
997149779b
2 arquivos alterados com 9 adições e 0 exclusões
  1. 1 0
      package.json
  2. 8 0
      src/server/index.js

+ 1 - 0
package.json

@@ -67,6 +67,7 @@
   },
   "dependencies": {
     "@babel/polyfill": "^7.2.5",
+    "body-parser": "^1.18.3",
     "express": "^4.16.4",
     "joi": "^14.3.1",
     "mongodb": "^3.1.10",

+ 8 - 0
src/server/index.js

@@ -1,4 +1,6 @@
 const express = require('express');
+const bodyParser = require('body-parser');
+
 const webpack = require('webpack');
 const path = require('path');
 
@@ -38,6 +40,10 @@ function clientRoute(config, db, logger, app) {
     app.use(express.static(path.resolve(__dirname, '../../static')));
 }
 
+function setupMiddleware(app) {
+    app.use(bodyParser.json());
+}
+
 async function run() {
     const config = getConfig();
     const logger = getLogger(config);
@@ -47,6 +53,8 @@ async function run() {
 
         const app = express();
 
+        setupMiddleware(app);
+
         healthEndpoint(config, db, logger, app);
         setupDevServer(config, db, logger, app);
         clientRoute(config, db, logger, app);