@aklinker1/zeta 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/package.json +1 -1
- package/src/schema.ts +2 -2
package/README.md
CHANGED
|
@@ -205,6 +205,31 @@ const app = createApp().post(
|
|
|
205
205
|
);
|
|
206
206
|
```
|
|
207
207
|
|
|
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(
|
|
221
|
+
"/upload",
|
|
222
|
+
{
|
|
223
|
+
body: UploadFilesBody,
|
|
224
|
+
},
|
|
225
|
+
({ body }) => {
|
|
226
|
+
console.log(body); // File[]
|
|
227
|
+
},
|
|
228
|
+
);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
For all the body utils, just pass them to the `body` property and inside the route handler, the `body` variable will be typed accordingly.
|
|
232
|
+
|
|
208
233
|
### Response
|
|
209
234
|
|
|
210
235
|
You can either define a single response or multiple responses.
|
package/package.json
CHANGED
package/src/schema.ts
CHANGED
|
@@ -222,8 +222,8 @@ export const UploadFileBody: ZetaSchema<File> = createZetaSchema<File>(
|
|
|
222
222
|
},
|
|
223
223
|
);
|
|
224
224
|
|
|
225
|
-
export const UploadFilesBody: ZetaSchema<
|
|
226
|
-
|
|
225
|
+
export const UploadFilesBody: ZetaSchema<FileList, File[]> = createZetaSchema<
|
|
226
|
+
FileList,
|
|
227
227
|
File[]
|
|
228
228
|
>(
|
|
229
229
|
"UploadFilesBody",
|