blomqma / next-rest-framework

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

Add Edge runtime compatibility #119

Closed blomqma closed 7 months ago

blomqma commented 8 months ago

This is a major change that simplifies the OpenAPI sepc generation process, and adds Edge runtime support.

Removing development-server generation:

This change completely removes the automatic local OpenAPI spec generation when calling the documentation endpoint and leaves the spec generation completely for the CLI which is now much more reliable for the following reason:

Previously the file system based OpenAPI spec generation done by the CLI used the build output generated by Next.js in the .next folder. This was however suboptimal as there's no guarantee that the module structure won't change between Next.js versions, breaking the CLI. A new approach is that the CLI commands generate and validate now generate a temporary build folder called .next-rest-framework which is compiled using ESBuild which produces consistent output from the CLI. This temporary folder is used to gather the OpenAPI paths from the generated routes and api routes that works with all Next.js versions. This is also much faster than running next build every time with the CLI.

With this changes, all Node.js file system based API calls etc. are split do a different bundle so that the code also works in the Edge runtime.

Fixed:

vercel[bot] commented 8 months 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 Jan 29, 2024 7:47pm
next-rest-framework-demo βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Jan 29, 2024 7:47pm