Files
docmost_custom/server/src/main.ts
T

39 lines
958 B
TypeScript
Raw Normal View History

2023-08-03 17:04:35 +01:00
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
2023-08-03 17:29:50 +01:00
import {
FastifyAdapter,
NestFastifyApplication,
} from '@nestjs/platform-fastify';
2023-08-05 16:58:34 +01:00
import { ValidationPipe } from '@nestjs/common';
2023-08-05 20:44:15 +01:00
import { TransformHttpResponseInterceptor } from './interceptors/http-response.interceptor';
2023-11-27 13:20:42 +00:00
import fastifyMultipart from '@fastify/multipart';
2023-08-03 17:04:35 +01:00
async function bootstrap() {
2023-08-03 17:29:50 +01:00
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter({
ignoreTrailingSlash: true,
ignoreDuplicateSlashes: true,
2023-11-27 13:20:42 +00:00
} as any),
2023-08-03 17:29:50 +01:00
);
2023-11-27 13:20:42 +00:00
app.setGlobalPrefix('api');
await app.register(fastifyMultipart);
2023-08-05 16:58:34 +01:00
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
stopAtFirstError: true,
}),
);
2023-08-20 13:43:45 +01:00
app.enableCors();
2023-08-05 16:58:34 +01:00
2023-08-05 20:44:15 +01:00
app.useGlobalInterceptors(new TransformHttpResponseInterceptor());
2023-10-16 15:19:30 +01:00
app.enableShutdownHooks();
2023-08-05 20:44:15 +01:00
2024-01-08 09:56:10 +01:00
await app.listen(process.env.PORT || 3000);
2023-08-03 17:04:35 +01:00
}
2023-11-27 13:20:42 +00:00
2023-08-03 17:04:35 +01:00
bootstrap();