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 ?
No description
4 Replies
IsraelOrtuno
IsraelOrtuno5mo ago
you could name them index.post.ts and index.get.ts inside the datasource folder
white_rqbbit
white_rqbbit5mo ago
✅ Works ! Thanks a lot @IsraelOrtuno
IsraelOrtuno
IsraelOrtuno5mo ago
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.
white_rqbbit
white_rqbbit5mo ago
Didn't know that option. The index solution works well for me, but it's nice to know this exists. Thanks again !
Want results from more Discord servers?
Add your server