Skip to content

[v5] Import files routes into routes/index and create a global group #3113

Answered by CodeRogers
jairochaves2 asked this question in Help
Discussion options

You must be logged in to vote

You can define your Route and export as function like these:

// Using resource:
import Route from '@ioc:Adonis/Core/Route'

export default function userRoutes() {
  Route.resource('users', 'UsersController').apiOnly()
}

// Using methods:
import Route from '@ioc:Adonis/Core/Route'

export default function authenticationRoutes() {
  Route.post('login', 'LoginController.store')
  Route.post('logout', 'LogoutController.store').middleware('auth')
}

// Using group: 
import Route from '@ioc:Adonis/Core/Route'

export default function companyRoutes() {
  Route.group(() => {
    Route.get('companies/user', 'Companies/SearchController.index')
    Route.resource('companies', 'Companies/CompaniesCo…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jairochaves2
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants