Skip to content

Commit 7224aa0

Browse files
committed
feat: support custom bodyParser option (or false)
1 parent 015a4c3 commit 7224aa0

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

index.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,22 @@ class API {
145145
// Body parser
146146
// POST /v1/logs (1 MB max so 1.1 MB w/overhead)
147147
// POST /v1/emails (50 MB max so 51 MB w/overhead)
148-
app.use((ctx, next) => {
149-
// check against ignored paths
150-
if (
151-
Array.isArray(this.config.bodyParserIgnoredPathGlobs) &&
152-
this.config.bodyParserIgnoredPathGlobs.length > 0
153-
) {
154-
const match = multimatch(
155-
ctx.path,
156-
this.config.bodyParserIgnoredPathGlobs
157-
);
158-
if (Array.isArray(match) && match.length > 0) return next();
159-
}
160-
161-
return bodyParser()(ctx, next);
162-
});
148+
if (this.config.bodyParser !== false)
149+
app.use((ctx, next) => {
150+
// check against ignored paths
151+
if (
152+
Array.isArray(this.config.bodyParserIgnoredPathGlobs) &&
153+
this.config.bodyParserIgnoredPathGlobs.length > 0
154+
) {
155+
const match = multimatch(
156+
ctx.path,
157+
this.config.bodyParserIgnoredPathGlobs
158+
);
159+
if (Array.isArray(match) && match.length > 0) return next();
160+
}
161+
162+
return bodyParser(this.config.bodyParser || {})(ctx, next);
163+
});
163164

164165
// Pretty-printed json responses
165166
app.use(json());

0 commit comments

Comments
 (0)