Search code examples
nestjs

how to do nested routing


Can someone recommend how to properly (nestjs way) implement nested router? For example,

/users/12/characters/765/tools

I'd like to have users controller and characters controller that is dependent on users (sub router) in separate files ( if this is not recommended way, could you suggest alternatives? ) thanks in advance!


Solution

  • You can do something like this in separate controllers:

    @Controller('users') 
    export class UsersController
    {...}
    
    @Controller('users/:userId/characters')
    export class CharactersController
    {...}