Skip to content

Commit

Permalink
patch: Use express.json & express.urlencoded directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Oct 26, 2017
1 parent 48f119a commit 637ec58
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const chalk = require('chalk')
const express = require('express')
const morgan = require('morgan')
const helmet = require('helmet')
const bodyParser = require('body-parser')

module.exports = async function ({ conf, log }) {
const httpOptions = conf.mono.http
Expand Down Expand Up @@ -53,8 +52,8 @@ module.exports = async function ({ conf, log }) {
}
// Middleware
if (httpOptions.helmet !== false) app.use(helmet(httpOptions.helmet))
if (httpOptions.bodyParser.urlencoded !== false) app.use(bodyParser.urlencoded(Object.assign({ extended: false }, httpOptions.bodyParser.urlencoded)))
if (httpOptions.bodyParser.json !== false) app.use(bodyParser.json(httpOptions.bodyParser.json))
if (httpOptions.bodyParser.urlencoded !== false) app.use(express.urlencoded(Object.assign({ extended: false }, httpOptions.bodyParser.urlencoded)))
if (httpOptions.bodyParser.json !== false) app.use(express.json(httpOptions.bodyParser.json))
// Logger middleware
if (typeof httpOptions.logLevel === 'string') {
app.use(morgan(httpOptions.logLevel, { stream: log.stream }))
Expand Down

0 comments on commit 637ec58

Please sign in to comment.