middy
Advanced tools
Comparing version 0.18.1 to 0.19.0
{ | ||
"name": "middy", | ||
"version": "0.18.1", | ||
"version": "0.19.0", | ||
"description": "🛵 The stylish Node.js middleware engine for AWS Lambda", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
const createError = require('http-errors') | ||
const contentType = require('content-type') | ||
const contentTypeLib = require('content-type') | ||
module.exports = () => ({ | ||
before: (handler, next) => { | ||
if (handler.event.headers && handler.event.headers['Content-Type']) { | ||
const { type } = contentType.parse(handler.event.headers['Content-Type']) | ||
const { headers } = handler.event | ||
if (!headers) { | ||
return next() | ||
} | ||
const contentType = headers['Content-Type'] || headers['content-type'] | ||
if (contentType) { | ||
const { type } = contentTypeLib.parse(contentType) | ||
if (type === 'application/json') { | ||
@@ -9,0 +14,0 @@ try { |
158956
4000