homemanager-be/src/main.ts

35 lines
981 B
TypeScript

import { ValidationPipe } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const configService = app.get(ConfigService);
const config = new DocumentBuilder()
.setTitle('Home Manager')
.setDescription('Home manager API')
.setVersion('1.0')
.addTag('users')
.addTag('groups')
.addTag('storage')
.addTag('buildings')
.addBearerAuth({
name: 'Bearer token',
type: 'apiKey',
})
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, document);
app.useGlobalPipes(
new ValidationPipe({
forbidNonWhitelisted: true,
whitelist: true,
}),
);
await app.listen(+configService.get('PORT'));
}
bootstrap();