Closed emilesabatier closed 4 months ago
This is not how you are expected to split your route. Also, note this has nothing to do with AdonisJS and is a more JavaScript-related question.
Thank you, I understand this is not AdonisJS related, so we can close the PR.
But what is the best AdonisJS way to split my routes ?
But what is the best AdonisJS way to split my routes ?
There is no "best" way, but I would recommend creating a dedicated file and declaring your route there, then importing it from your main file.
// start/routes/v1.ts
import router from '@adonisjs/core/services/router'
router.group(() => {
router.get('/nome', () => 'Adonis')
}).prefix('api/v1')
// start/routes.ts
import './routes/v1.js'
router.group(() => {
router.get('/nome', () => 'Adonis')
}).prefix('api')
Hi, first PR here!
Had some difficulties to find out why splitting my routes into differents files was not working.
Found the answer thanks to Soares on the discord: https://discord.com/channels/423256550564691970/1204948136163020852
One must export a function. It could be useful to be mentionned in the docs, mainspring of this PR.