54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { AppModule } from './app.module';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
import { Logger } from '@nestjs/common';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule);
|
|
|
|
const swaggerConfig = new DocumentBuilder()
|
|
.setTitle('MultiTenant Saas')
|
|
.setDescription(`API Documentation for a simple MultiTenant Saas Application`)
|
|
.setVersion('0.0.1')
|
|
.addGlobalResponse(
|
|
{
|
|
status: 500,
|
|
description: 'Internal Server Error',
|
|
},
|
|
{
|
|
status: 401,
|
|
description: 'Unauthorized',
|
|
},
|
|
{
|
|
status: 403,
|
|
description: 'Forbidden',
|
|
},
|
|
)
|
|
.addBearerAuth(
|
|
{
|
|
type: 'http',
|
|
scheme: 'bearer',
|
|
bearerFormat: 'JWT',
|
|
},
|
|
'access-token',
|
|
)
|
|
.build();
|
|
|
|
const documentFactory = () =>
|
|
SwaggerModule.createDocument(app, swaggerConfig);
|
|
SwaggerModule.setup('/docs', app, documentFactory, {
|
|
swaggerOptions: {
|
|
persistAuthorization: true,
|
|
},
|
|
});
|
|
|
|
const config = app.get(ConfigService);
|
|
const port = config.get<number>('PORT') ?? 3000;
|
|
|
|
await app.listen(port);
|
|
|
|
Logger.log(`Listning on port ${port}`)
|
|
}
|
|
bootstrap();
|