import { join } from "path";
import { NestFactory } from "@nestjs/core";
import { NestExpressApplication } from "@nestjs/platform-express";
import * as nunjucks from "nunjucks";
import * as helmet from "helmet";
import { ApplicationModule } from "./app.module";
async function bootstrap() {
let options: any = {};
if (process.env.NODE_ENV === "product") options.logger = false;
const app = await NestFactory.create<NestExpressApplication>(
ApplicationModule,
options
);
app.use(helmet());
// app.useGlobalPipes(
// new ValidationPipe({
// whitelist: true,
// validationError: { target: false, value: false },
// }),
// );
app.useStaticAssets(join(__dirname, "..", "public"), { prefix: "/static/" });
const environment = nunjucks.configure(
[
join(__dirname, "..", "template"),
join(__dirname, ".", "system_template")
],
{
autoescape: true,
throwOnUndefined: false,
trimBlocks: false,
lstripBlocks: false,
watch: true,
noCache: process.env.NODE_ENV === "local" ? true : false,
express: app
}
);
app.engine("njk", environment.render);
app.setViewEngine("njk");
app.set("view cache", true);
await app.listen(process.env.APP_PORT);
}
bootstrap();