Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
realtux committed Jan 2, 2025
1 parent a77a104 commit 849361f
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions docs/docs/modules/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,58 @@ middleware = {
```

middleware precedence is top to bottom. this is why everything works in the third example. `hello` has a value of blank array.

## request parsers

### application/json

`req.body` is populated with the parsed version of the request.

```json
{"name": "exa", "type": "framework"}
```

is parsed into

```js
{
name: 'exa',
type: 'framework'
}
```

### application/x-www-form-urlencoded

`req.body` is populated with an object of key/value pairs representing the request.

```
?name=exa&type=framework
```

is parsed into

```js
{
name: 'exa',
type: 'framework'
}
```

### multipart/form-data

same as above, `req.body` is populated with an object of key/value pairs representing the request **for only non-files**. `exa.js` uses [multer](https://www.npmjs.com/package/multer) middleware for `multipart/form-data` requests. by default, the in memory temporary storage is used.

for `multipart/form-data` requests, `req.files` is populated with an array of objects each representing an uploaded file. for example, a file uploaded with the name `cat` would cause `req.files` to look like this:

```js
[
{
fieldname: 'cat',
originalname: 'cool_cat.jpg',
encoding: '7bit',
mimetype: 'image/jpeg',
buffer: <Buffer ff d8 ff e1 7f ... 1024 more bytes>,
size: 7972467
}
]
```

0 comments on commit 849361f

Please sign in to comment.