diff --git a/_includes/api/en/4x/express.json.md b/_includes/api/en/4x/express.json.md index ffc460193d..70f0b7cbe2 100644 --- a/_includes/api/en/4x/express.json.md +++ b/_includes/api/en/4x/express.json.md @@ -39,4 +39,4 @@ The following table describes the properties of the optional `options` object. | `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"` | | `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` | - \ No newline at end of file + diff --git a/_includes/api/en/4x/express.static.md b/_includes/api/en/4x/express.static.md index b92c2d7b36..7db89cf051 100644 --- a/_includes/api/en/4x/express.static.md +++ b/_includes/api/en/4x/express.static.md @@ -93,3 +93,13 @@ var options = { app.use(express.static('public', options)) ``` +

Example of express.json

+ +Here is an example of using the `express.json` middleware function with a custom limit: + +```js +// Apply a 5MB limit for /upload requests +app.use('/upload', express.json({ limit: '5mb' })) + +// Use default limit for all other routes +app.use(express.json()) diff --git a/_includes/api/en/5x/app-use.md b/_includes/api/en/5x/app-use.md index c4806291b7..71daff693a 100644 --- a/_includes/api/en/5x/app-use.md +++ b/_includes/api/en/5x/app-use.md @@ -138,6 +138,23 @@ app.use(['/abcd', '/xyza', /\/lmn|\/pqr/], (req, res, next) => { +> **Note:** The above path examples describe how `app.use()` matches paths. +> When using route methods (such as `app.get()`, `app.post()`, etc.), the path must match exactly. +> For example: +> +> ```js +> app.use('/api', (req, res, next) => { +> // Matches /api, /api/users, /api/orders/123 +> next() +> }) +> +> app.get('/api', (req, res) => { +> // Only matches /api +> res.send('Hello API') +> }) +> ``` + + #### Middleware callback function examples The following table provides some simple examples of middleware functions that