Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to increase the raw body limit that bodyParser can handle #6

Merged
merged 2 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.3.0
v16
5 changes: 5 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function run (opts = {}) {
--default-cors, -C Add "default" cors using https://www.npmjs.com/package/cors default values. By default only enabled for non-proxied responses. Turn on to enable also for proxy responses, turn off to disable completely.
--silent-start, Do not log "listening", proxy mapping or any other status on start. Only requests and responses.
--mock-date, Use mocked date value for value of "now". https://www.npmjs.com/package/mockdate
--raw-body-limit, Max size of raw body supported. Number of bytes or string parseable by bytes library. Default is '5Mb'.
--indent-response, On by default. Indents response with console.group() when using node >= v8.5.0
--sort-fields, Off by default. Pretty print headers, query parameters and url-form body fields in sorted order. Does not apply to json bodies.
Examples
Expand All @@ -54,6 +55,9 @@ export default function run (opts = {}) {
# Turn off response logging
$ console-log-server -r no

# Receive and log raw bodies up to 10Mb
$ console-log-server -l "10Mb"

# Turn on response logging for all requests
$ console-log-server -r yes

Expand All @@ -78,6 +82,7 @@ export default function run (opts = {}) {
C: 'default-cors',
S: 'silent-start',
D: 'mock-date',
l: 'raw-body-limit',
i: 'indent-response',
s: 'sort-fields'
},
Expand Down
1 change: 1 addition & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export default opts => {
)
router.use(
bodyParser.raw({
limit: opts.rawBodyLimit === undefined ? '5Mb' : opts.rawBodyLimit,
type: () => true,
verify: (/** @type {RequestExt} */ req) => {
req.locals.bodyType = 'raw'
Expand Down
1 change: 1 addition & 0 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @property {string | string[]} [hostname]
* @property {boolean} [silentStart]
* @property {string | number | Date} [mockDate]
* @property {string | number} [rawBodyLimit]
* @property {boolean} [indentResponse]
* @property {boolean} [color]
* @property {boolean} [sortFields]
Expand Down