first commit
This commit is contained in:
35
myteamwallet_backend/src/main.ts
Normal file
35
myteamwallet_backend/src/main.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { ValidationPipe, VersioningType } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { useContainer } from 'class-validator';
|
||||
import { AppModule } from './app.module';
|
||||
import validationOptions from './utils/validation-options';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule, { cors: true });
|
||||
useContainer(app.select(AppModule), { fallbackOnErrors: true });
|
||||
const configService = app.get(ConfigService);
|
||||
|
||||
app.enableShutdownHooks();
|
||||
app.setGlobalPrefix(configService.get('app.apiPrefix'), {
|
||||
exclude: ['/'],
|
||||
});
|
||||
app.enableVersioning({
|
||||
type: VersioningType.URI,
|
||||
});
|
||||
app.useGlobalPipes(new ValidationPipe(validationOptions));
|
||||
|
||||
const options = new DocumentBuilder()
|
||||
.setTitle('API')
|
||||
.setDescription('API docs')
|
||||
.setVersion('1.0')
|
||||
.addBearerAuth()
|
||||
.build();
|
||||
|
||||
const document = SwaggerModule.createDocument(app, options);
|
||||
SwaggerModule.setup('docs', app, document);
|
||||
|
||||
await app.listen(configService.get('app.port'));
|
||||
}
|
||||
void bootstrap();
|
||||
Reference in New Issue
Block a user