2022-10-09 22:30:32 +02:00
|
|
|
import { ClassSerializerInterceptor, ValidationPipe } from "@nestjs/common";
|
|
|
|
import { NestFactory, Reflector } from "@nestjs/core";
|
2022-10-24 12:11:10 +02:00
|
|
|
import { NestExpressApplication } from "@nestjs/platform-express";
|
2023-02-07 11:23:43 +01:00
|
|
|
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
|
2023-01-09 11:43:48 +01:00
|
|
|
import * as bodyParser from "body-parser";
|
2023-01-04 11:54:28 +01:00
|
|
|
import * as cookieParser from "cookie-parser";
|
2022-10-09 22:30:32 +02:00
|
|
|
import * as fs from "fs";
|
|
|
|
import { AppModule } from "./app.module";
|
2022-10-24 12:11:10 +02:00
|
|
|
|
2022-10-09 22:30:32 +02:00
|
|
|
async function bootstrap() {
|
2022-10-24 12:11:10 +02:00
|
|
|
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
2022-12-05 16:54:15 +01:00
|
|
|
app.useGlobalPipes(new ValidationPipe({ whitelist: true }));
|
2022-10-09 22:30:32 +02:00
|
|
|
app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));
|
|
|
|
|
2023-01-13 10:16:35 +01:00
|
|
|
app.use(bodyParser.raw({ type: "application/octet-stream", limit: "20mb" }));
|
2023-01-04 11:54:28 +01:00
|
|
|
app.use(cookieParser());
|
2022-10-24 12:11:10 +02:00
|
|
|
app.set("trust proxy", true);
|
|
|
|
|
2022-10-12 00:38:38 +02:00
|
|
|
await fs.promises.mkdir("./data/uploads/_temp", { recursive: true });
|
2022-10-09 22:30:32 +02:00
|
|
|
|
|
|
|
app.setGlobalPrefix("api");
|
2023-02-07 11:23:43 +01:00
|
|
|
|
|
|
|
// Setup Swagger in development mode
|
|
|
|
if (process.env.NODE_ENV == "development") {
|
|
|
|
const config = new DocumentBuilder()
|
|
|
|
.setTitle("Pingvin Share API")
|
|
|
|
.setVersion("1.0")
|
|
|
|
.build();
|
|
|
|
const document = SwaggerModule.createDocument(app, config);
|
|
|
|
SwaggerModule.setup("api/swagger", app, document);
|
|
|
|
}
|
|
|
|
|
2023-04-25 23:39:57 +02:00
|
|
|
await app.listen(process.env.PORT || 8080);
|
2022-10-09 22:30:32 +02:00
|
|
|
}
|
|
|
|
bootstrap();
|