Skip to content

Commit

Permalink
Resolve i13 Body Parser (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ealenn authored Nov 23, 2019
1 parent 7bf53d0 commit e468516
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 3 deletions.
168 changes: 168 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
},
"homepage": "https://github.com/Ealenn/Echo-Server#readme",
"dependencies": {
"body-parser": "^1.19.0",
"cookie-parser": "^1.4.4",
"express": "^4.17.1",
"multer": "^1.4.2",
"nconf": "^0.10.0"
}
}
16 changes: 13 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const express = require('express')();
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const multer = require('multer')();
const config = require('./nconf');

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.text());
app.use(bodyParser.json());
app.use(cookieParser());
app.use(multer.array());

function response(req) {
if (req.originalUrl != "/ping" || !config.get('logs:ignore:ping')) {
console.log(`${Date.now()} | [${req.method}] - ${req.protocol}://${req.get('host')}${req.originalUrl}`);
Expand Down Expand Up @@ -29,5 +39,5 @@ function response(req) {
}
};

express.all('*', (req, res) => res.json(response(req)));
express.listen(config.get('port'), () => console.log(`Listening on port ${config.get('port')}.`));
app.all('*', (req, res) => res.json(response(req)));
app.listen(config.get('port'), () => console.log(`Listening on port ${config.get('port')}.`));

0 comments on commit e468516

Please sign in to comment.