I want to add routing prefixes at the module level and/or have complex global routing prefix logic in general.
I know I can use the undocumented function NestApplication.setGlobalPrefix
to set a single global prefix:
// main.ts
app.setGlobalPrefix(version);
However, I want to set prefixes at the module level in this case.
It appears I could achieve this by setting my desired prefix into the decorators at the controller level:
//controler.ts
@Get('/PREFIX/health')
async getHealth() {
// TODO: implement
return {};
}
But this seems fairly hacky and error-prone. Surely there is a better way?