Skip to content

Instantly share code, notes, and snippets.

@Gobot1234
Created January 29, 2024 01:47
Show Gist options
  • Save Gobot1234/0014e5cec5d049af18d6359a7f58c7c1 to your computer and use it in GitHub Desktop.
Save Gobot1234/0014e5cec5d049af18d6359a7f58c7c1 to your computer and use it in GitHub Desktop.
import { ValidationPipe, VersioningType } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import helmet from 'helmet';
import { AppModule } from './app.module';
import { AllExceptionsFilter } from './filters/all-exceptions/all-exceptions.filter';
import { ResponseFormatService } from './response-format/response-format.service';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableShutdownHooks();
app.enableCors();
// Options
app.enableVersioning({
defaultVersion: '1',
type: VersioningType.URI,
});
app.useGlobalPipes(new ValidationPipe());
app.use(helmet());
app.useGlobalFilters(new AllExceptionsFilter(new ResponseFormatService()));
// Open API
const options = new DocumentBuilder()
.setTitle('iForge Anvil')
.setDescription('iForge Anvil API')
.setVersion('0.1')
.addTag('iForge')
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
await app.listen(3000);
}
bootstrap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment