File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const etag = require('koa-etag');
1919const json = require ( 'koa-json' ) ;
2020const koa404Handler = require ( 'koa-404-handler' ) ;
2121const koaConnect = require ( 'koa-connect' ) ;
22+ const multimatch = require ( 'multimatch' ) ;
2223const ratelimit = require ( '@ladjs/koa-simple-ratelimit' ) ;
2324const removeTrailingSlashes = require ( 'koa-no-trailing-slash' ) ;
2425const requestId = require ( 'express-request-id' ) ;
@@ -129,7 +130,23 @@ class API {
129130 }
130131
131132 // Body parser
132- app . use ( bodyParser ( ) ) ;
133+ // POST /v1/logs (1 MB max so 1.1 MB w/overhead)
134+ // POST /v1/emails (50 MB max so 51 MB w/overhead)
135+ app . use ( ( ctx , next ) => {
136+ // check against ignored paths
137+ if (
138+ Array . isArray ( this . config . bodyParserIgnoredPathGlobs ) &&
139+ this . config . bodyParserIgnoredPathGlobs . length > 0
140+ ) {
141+ const match = multimatch (
142+ ctx . path ,
143+ this . config . bodyParserIgnoredPathGlobs
144+ ) ;
145+ if ( Array . isArray ( match ) && match . length > 0 ) return next ( ) ;
146+ }
147+
148+ return bodyParser ( ) ( ctx , next ) ;
149+ } ) ;
133150
134151 // Pretty-printed json responses
135152 app . use ( json ( ) ) ;
Original file line number Diff line number Diff line change 3434 "koa-json" : " ^2.0.2" ,
3535 "koa-no-trailing-slash" : " ^2.1.0" ,
3636 "lodash" : " ^4.17.21" ,
37+ "multimatch" : " 5" ,
3738 "request-received" : " ^0.0.3" ,
3839 "response-time" : " ^2.3.2"
3940 },
You can’t perform that action at this time.
0 commit comments