Replies: 1 comment
-
export { handler as POST, handler as GET, handler as PUT } |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
Next.js is an amazing tool for frontend and full stack app... but it can be really usefull for building serverless backends very quickly, and with the vercel platform you can deploy them on edge trivially.
I was building an automatic crud library with drizzle-orm and so far in order to make it work the structure of the routes is:
app/api/[table]/route.js (export GET, POST)
app/api/[table]/[id]/route.js (export GET, PUT, PATCH, DELETE)
If I had the possibility to define a single default export and handle HTTP methods from there it would look something like this:
app/api/[...crud]/route.js (export default)
Proposal
Next.js should check for handlers in named exports first, and then if it finds a default export it should apply it to the HTTP methods that were not in the named exports.
Beta Was this translation helpful? Give feedback.
All reactions