feat: Basic setup with auth

This commit is contained in:
sauravdhakal12
2026-02-21 17:21:48 +05:45
parent f6bce78aee
commit f4c9174752
24 changed files with 418 additions and 18 deletions

View File

@@ -1,10 +1,47 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ConfigService } from '@nestjs/config';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const swaggerConfig = new DocumentBuilder()
.setTitle('Kaa Khane')
.setDescription(`API Documentation for Kaa Khane`)
.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;