@ladjs/api 14.1.1 → 14.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +18 -1
  2. package/package.json +2 -1
package/index.js CHANGED
@@ -19,6 +19,7 @@ const etag = require('koa-etag');
19
19
  const json = require('koa-json');
20
20
  const koa404Handler = require('koa-404-handler');
21
21
  const koaConnect = require('koa-connect');
22
+ const multimatch = require('multimatch');
22
23
  const ratelimit = require('@ladjs/koa-simple-ratelimit');
23
24
  const removeTrailingSlashes = require('koa-no-trailing-slash');
24
25
  const requestId = require('express-request-id');
@@ -129,7 +130,23 @@ class API {
129
130
  }
130
131
 
131
132
  // 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
+ });
133
150
 
134
151
  // Pretty-printed json responses
135
152
  app.use(json());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ladjs/api",
3
3
  "description": "API server for Lad",
4
- "version": "14.1.1",
4
+ "version": "14.1.2",
5
5
  "author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/ladjs/api/issues",
@@ -34,6 +34,7 @@
34
34
  "koa-json": "^2.0.2",
35
35
  "koa-no-trailing-slash": "^2.1.0",
36
36
  "lodash": "^4.17.21",
37
+ "multimatch": "5",
37
38
  "request-received": "^0.0.3",
38
39
  "response-time": "^2.3.2"
39
40
  },