Skip to content

Commit 7f11fe5

Browse files
committed
docs: Document file upload and form data body types usage
1 parent 5e74f08 commit 7f11fe5

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,27 @@ const app = createApp().post(
205205
);
206206
```
207207

208+
#### Request Body Utils
209+
210+
- `FormDataBody`: Upload `FormData` instances
211+
- `UploadFileBody`: Use `FormData` to upload a single file
212+
- `UploadFilesBody`: Use `FormData` to upload multiple files
213+
214+
Here's an example:
215+
216+
```ts
217+
import { createApp } from "@aklinker1/zeta";
218+
import { UploadFilesBody } from "@aklinker1/zeta/schema";
219+
220+
const app = createApp().post("/upload", {
221+
body: UploadFilesBody,
222+
}, ({ body }) => {
223+
console.log(body); // File[]
224+
});
225+
```
226+
227+
For all the body utils, just pass them to the `body` property and inside the route handler, the `body` variable will be typed accordingly.
228+
208229
### Response
209230

210231
You can either define a single response or multiple responses.

0 commit comments

Comments
 (0)