Server/src/main.ts

36 lines
924 B
TypeScript
Raw Normal View History

2024-12-02 14:25:36 +00:00
import { ClassSerializerInterceptor, ValidationPipe } from "@nestjs/common";
import { NestFactory, Reflector } from "@nestjs/core";
2024-12-02 14:25:36 +00:00
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
2024-11-23 00:37:22 +00:00
import { AppModule } from "./app.module";
async function bootstrap() {
const app = await NestFactory.create(AppModule);
2024-11-24 01:34:20 +00:00
app.enableCors({
origin: "*",
2024-11-24 01:34:20 +00:00
});
app.useGlobalPipes(new ValidationPipe());
2024-12-02 14:25:36 +00:00
app.useGlobalInterceptors(
new ClassSerializerInterceptor(app.get(Reflector), {
excludeExtraneousValues: true,
}),
);
const config = new DocumentBuilder()
.setTitle("Toogether API")
.addBearerAuth()
.build();
const documentFactory = () => SwaggerModule.createDocument(app, config);
SwaggerModule.setup("documentation", app, documentFactory, {
swaggerOptions: {
tryItOutEnabled: true,
persistAuthorization: true,
}
});
await app.listen(process.env.PORT ?? 3000, "0.0.0.0");
2024-11-23 00:37:22 +00:00
}
bootstrap();