Add requireJson middleware
This commit is contained in:
parent
b45aacc25a
commit
5af6122646
9
src/middlewares/requireJson.middlewares.js
Normal file
9
src/middlewares/requireJson.middlewares.js
Normal file
@ -0,0 +1,9 @@
|
||||
const log = require('../utils/log.utils')
|
||||
|
||||
module.exports = async function requireJson(req, res, next) {
|
||||
if (req.headers['content-type'] !== 'application/json') {
|
||||
res.status(400).send({status: 400, message: "Server requires JSON"})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user