43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { AppModule } from './app.module';
|
|
import {
|
|
SwaggerModule,
|
|
DocumentBuilder,
|
|
SwaggerCustomOptions,
|
|
} from '@nestjs/swagger';
|
|
import { ValidationPipe } from '@nestjs/common';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule);
|
|
const apiVersion = 1;
|
|
|
|
if (process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'test') {
|
|
const config = new DocumentBuilder()
|
|
.setTitle('Moeum API')
|
|
.setDescription('The Moeum API description')
|
|
.setVersion('1.0')
|
|
.addTag('moeum')
|
|
.addServer(`https://moeum.dahyeon.us/`)
|
|
.addBearerAuth({
|
|
type: 'openIdConnect',
|
|
})
|
|
.build();
|
|
const options: SwaggerCustomOptions = {
|
|
ui: true,
|
|
raw: ['json'],
|
|
};
|
|
const documentFactory = () => SwaggerModule.createDocument(app, config);
|
|
SwaggerModule.setup(`v${apiVersion}/api`, app, documentFactory, options);
|
|
}
|
|
|
|
app.setGlobalPrefix(`v${apiVersion}`);
|
|
app.enableCors();
|
|
app.useGlobalPipes(
|
|
new ValidationPipe({
|
|
transform: true,
|
|
}),
|
|
);
|
|
await app.listen(process.env.PORT ?? 3415);
|
|
}
|
|
bootstrap();
|