How to use NestJS Versioning with Router module

Viewed 76

In our nest 8 project we use the RouterModule for routing between different parts of the app:

@Module({
  imports: [
    RouterModule.register([
      {
        path: '/internal',
        module: InternalModule
      },
      {
        path: '/external',
        module: ExternalModule
      }
    ]),
  ],
})
export class AppModule {}

In the InternalModule we would like to use NestJS versioning:

@Controller('someroute')
export class InternalController {
  @Get(':id')
  @Version(['1'])
  async getPerson(@Param('id') id): Promise<any> {}
}

Routing without versioning works, versioning without routing too, but the combination does not. I tried calling it via "localhost:port/v1/internal/someroute" and "localhost:port/internal/v1/someroute"

Versioning is enabled:

app.enableVersioning({
  type: VersioningType.URI
});
0 Answers
Related