Skip to content
Closed
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 _includes/api/en/4x/express.json.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |

</div>
</div>
10 changes: 10 additions & 0 deletions _includes/api/en/4x/express.static.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,13 @@ var options = {

app.use(express.static('public', options))
```
<h4 id='example.of.express.json'>Example of express.json</h4>

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())
17 changes: 17 additions & 0 deletions _includes/api/en/5x/app-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,23 @@ app.use(['/abcd', '/xyza', /\/lmn|\/pqr/], (req, res, next) => {
</table>
</div>

> **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
Expand Down
Loading