http-body-parser
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -14,3 +14,3 @@ 'use strict'; | ||
class ParserFactory { | ||
constructor(req, enableTypes = ['json', 'form', 'text', 'multipart', 'stream'], parsers = {}) { | ||
constructor(req, enableTypes = ['json', 'form', 'text', 'multipart', 'stream'], parsers = []) { | ||
this.req = req; | ||
@@ -21,6 +21,7 @@ this.enableTypes = enableTypes; | ||
addParser(name, _Parser, options = {}) { | ||
addParser(type, _Parser, options = {}) { | ||
const Parser = _Parser; | ||
Parser.type = type; | ||
Parser.options = options; | ||
this.parsers[name] = Parser; | ||
this.parsers.push(Parser); | ||
} | ||
@@ -43,4 +44,4 @@ | ||
let parser = null; | ||
Object.entries(this.parsers).forEach(([name, Parser]) => { | ||
if (this.enableTypes.includes(name)) { | ||
this.parsers.forEach(Parser => { | ||
if (this.enableTypes.includes(Parser.type)) { | ||
if ((0, _TypeIs2.default)(this.req, Parser.getTypes(Parser.options.extendsTypes))) { | ||
@@ -47,0 +48,0 @@ parser = new Parser(body, this.req.headers, Parser.options.limit, Parser.options.path); |
{ | ||
"name": "http-body-parser", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "🎨 A body parser for node, koa, koa2, express. support json, form, text, multipart and stream type body.", | ||
@@ -48,2 +48,3 @@ "main": "lib/index.js", | ||
"babel-cli": "^6.24.1", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-env": "^1.4.0", | ||
@@ -50,0 +51,0 @@ "eslint": "^3.19.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
708950
42
596
10