Skip to content

Commit c89d966

Browse files
authored
Merge pull request #366 from ScryCollective/master
add bodyParserJsonOpts to apiConfig for setting the limit option
2 parents cfc237b + 167724c commit c89d966

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

documentation/configuring.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ jsonApi.setConfig({
2626
// (optional) meta can be a function to be invoked at the end of every request
2727
meta: function(request) {
2828
return { timestamp: new Date() };
29+
},
30+
// (optional) bodyParserJsonOpts allows setting the options passed to the json body parser,
31+
// such as the maximum allowed body size (default is 100kb). All the options are
32+
// documented at https://github.com/expressjs/body-parser#bodyparserjsonoptions
33+
bodyParserJsonOpts: {
34+
limit: '256kb',
2935
}
3036
});
3137
```

lib/router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ router.applyMiddleware = () => {
6666
return next()
6767
})
6868

69-
app.use(bodyParser.json())
69+
app.use(bodyParser.json(jsonApi._apiConfig.bodyParserJsonOpts))
7070
app.use(bodyParser.urlencoded({ extended: true }))
7171
app.use(cookieParser())
7272
if (!jsonApi._apiConfig.router) {

0 commit comments

Comments
 (0)