blomqma / next-rest-framework

Type-safe, self-documenting APIs for Next.js
https://next-rest-framework.vercel.app
Other
155 stars 20 forks source link

Add support for strongly-typed NextResponse #91

Closed blomqma closed 1 year ago

blomqma commented 1 year ago

Previously, the problem with App Router was that truly strongly-typed responses were not possible due to the NextResponse class not supporting a generic typing of the status codes. This change adds a patched TypedNextResponse class that adds support for type-checking the response status codes based on the output schema.

In order to achieve this, the user must import the TypedNextResponse class from Next REST Framework, but the good thing is that this is fully optional and using the plain NextResponse is still supported if the user prefers not to have strongly typed status code checks.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-rest-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 23, 2023 9:32pm
next-rest-framework-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 23, 2023 9:32pm