33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
|
|
import { VersioningType } from '@nestjs/common'
|
||
|
|
import { NestFactory } from '@nestjs/core'
|
||
|
|
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
|
||
|
|
import { AppModule } from './app.module'
|
||
|
|
import { LoggingInterceptor } from './common/interceptors/logging.interceptor'
|
||
|
|
import { ResponseMappingInterceptor } from './common/interceptors/response-mapping.interceptor'
|
||
|
|
|
||
|
|
async function bootstrap() {
|
||
|
|
const app = await NestFactory.create(AppModule)
|
||
|
|
|
||
|
|
const config = new DocumentBuilder()
|
||
|
|
.setTitle('Pos')
|
||
|
|
.setDescription('The Pos API description')
|
||
|
|
.setVersion('1.0')
|
||
|
|
.addTag('pos')
|
||
|
|
.build()
|
||
|
|
const documentFactory = () => SwaggerModule.createDocument(app, config)
|
||
|
|
SwaggerModule.setup('swagger', app, documentFactory)
|
||
|
|
|
||
|
|
// Set API prefix and enable URI versioning so all routes live under /api/v1/*
|
||
|
|
app.setGlobalPrefix('api')
|
||
|
|
app.enableVersioning({
|
||
|
|
type: VersioningType.URI,
|
||
|
|
defaultVersion: '1',
|
||
|
|
})
|
||
|
|
|
||
|
|
// Register global logging and response mapping interceptors
|
||
|
|
app.useGlobalInterceptors(new LoggingInterceptor(), new ResponseMappingInterceptor())
|
||
|
|
|
||
|
|
await app.listen(process.env.PORT ?? 3000)
|
||
|
|
}
|
||
|
|
bootstrap()
|