Skip to content

Commit

Permalink
Improve form support
Browse files Browse the repository at this point in the history
This adds support for strongly-typed
form data using the `zod-form-data`
schema that are now supported alongside
regular Zod schemas.

Pages router router routes now support
validating and strongly typing form data
requests that have the `application/x-www-form-urlencoded`,
whereas app router routes also support strongly typed
`multipart/form-data` requests using the `req.formData()`
method from the NextRequest object.

Because RPC routes share the common `rpcOperation`
method for both pages and app router, strongly typed form
data is for now only supported with the `application/x-www-form-urlencoded`
content type. (+1 squashed commit)
Squashed commits:
[5e4cf8d] Improve form support

This adds support for strongly-typed
form data using the `zod-form-data`
schema that are now supported alongside
regular Zod schemas.

Pages router router routes now support
validating and strongly typing form data
requests that have the `application/x-www-form-urlencoded`,
whereas app router routes also support strongly typed
`multipart/form-data` requests using the `req.formData()`
method from the NextRequest object.

Because RPC routes share the common `rpcOperation`
method for both pages and app router, strongly typed form
data is for now only supported with the `application/x-www-form-urlencoded`
content type.
  • Loading branch information
blomqma committed Mar 24, 2024
1 parent d6d9929 commit 492fce4
Show file tree
Hide file tree
Showing 44 changed files with 3,260 additions and 1,103 deletions.
3 changes: 2 additions & 1 deletion apps/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"lint": "tsc && next lint"
},
"dependencies": {
"next-rest-framework": "workspace:*"
"next-rest-framework": "workspace:*",
"zod-form-data": "2.0.2"
},
"devDependencies": {
"autoprefixer": "10.0.1",
Expand Down
Loading

0 comments on commit 492fce4

Please sign in to comment.