API routes directory
I'd like to have all my routes grouped together.
In the image example I provide, everything works fine, but
datasource.get.ts
and datasource.post.ts
are outside of the /datasource
directory.
Is there a way to do so ?4 Replies
you could name them
index.post.ts
and index.get.ts
inside the datasource
folder✅ Works ! Thanks a lot @IsraelOrtuno
you could also use the nested router if you think this may help to keep your code organised https://nuxt.com/docs/guide/directory-structure/server#nested-router
Nuxt
server/ · Nuxt Directory Structure
The server/ directory is used to register API and server handlers to your application.
Didn't know that option. The index solution works well for me, but it's nice to know this exists.
Thanks again !