Skip to content

Commit b6c6192

Browse files
committed
docs(express.json): add example for route-specific limits (#1421)
1 parent c2e3f31 commit b6c6192

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

_includes/api/en/4x/express.json.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,13 @@ The following table describes the properties of the optional `options` object.
3939
| `type` | This is used to determine what media type the middleware will parse. This option can be a string, array of strings, or a function. If not a function, `type` option is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) library and this can be an extension name (like `json`), a mime type (like `application/json`), or a mime type with a wildcard (like `*/*` or `*/json`). If a function, the `type` option is called as `fn(req)` and the request is parsed if it returns a truthy value. | Mixed | `"application/json"` |
4040
| `verify` | This option, if supplied, is called as `verify(req, res, buf, encoding)`, where `buf` is a `Buffer` of the raw request body and `encoding` is the encoding of the request. The parsing can be aborted by throwing an error. | Function | `undefined` |
4141

42-
</div>
42+
</div>
43+
44+
#### Example: Different limits for specific routes
45+
46+
```js
47+
// Limit 5MB for /upload
48+
app.use('/upload', express.json({ limit: '5mb' }));
49+
50+
// Default limit for other routes
51+
app.use(express.json());

0 commit comments

Comments
 (0)