-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global route for all controllers #40
Comments
I was wondering about the same. In express you can prepend paths by using the Router, and then: app.use('/a-route', aModule) Is this existing in nest, or is a feature request? |
@jezikk or combine it with https://github.com/pleerock/routing-controllers |
Very interesting, that library allows both global prefixes and per-controller prefixes, such as: @Controller("/users")
export class UserController {
// ...
} |
Hi @jezikk, const app = NestFactory.create(ApplicationModule);
app.setGlobalPrefix('api'); |
Should this work with swagger? import {NestFactory} from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
// ....
const app = await NestFactory.create(AppModule);
app.setGlobalPrefix('v1');
const options = new DocumentBuilder()
.setTitle('title')
.setDescription('API description')
.setVersion('0.1')
.addTag('tag')
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('docs', app, document);
// .... This doesn't add v1 as prefix in the documentation reflected on /docs/, but is reflected to the api, so I have to call /v1/... to get the endpoint. Is this a bug? |
As you can create multiple swagger documents (like, for every API version) it makes sense that it is no automatically derived from |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi,
is there any suggested way how to set a "global" route for all controllers?
For example, I want to define this route:
/api/
for my controllers:
with the following result:
Thank you
The text was updated successfully, but these errors were encountered: