@curveball/bodyparser
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -0,1 +1,7 @@ | ||
0.2.2 (2018-09-05) | ||
================== | ||
* Fixed bug: Body parsing wasn't awaited. | ||
0.2.1 (2018-09-05) | ||
@@ -2,0 +8,0 @@ ================== |
@@ -9,3 +9,3 @@ "use strict"; | ||
return async (ctx, next) => { | ||
parse(ctx); | ||
await parse(ctx); | ||
return next(); | ||
@@ -15,16 +15,14 @@ }; | ||
exports.default = bodyParser; | ||
async function parse(ctx) { | ||
function parse(ctx) { | ||
const type = ctx.request.type; | ||
if (type === 'application/json' || /^application\/(.*)\+json$/.test(type)) { | ||
parseJson(ctx); | ||
return; | ||
return parseJson(ctx); | ||
} | ||
if (type === 'application/x-www-form-urlencoded') { | ||
parseUrlEncoded(ctx); | ||
return; | ||
return parseUrlEncoded(ctx); | ||
} | ||
if (type.startsWith('text/')) { | ||
parseText(ctx); | ||
return; | ||
return parseText(ctx); | ||
} | ||
return Promise.resolve(); | ||
} | ||
@@ -31,0 +29,0 @@ async function parseJson(ctx) { |
{ | ||
"name": "@curveball/bodyparser", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A curveball middleware for parsing JSON and Text bodies.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
6484
43