33 lines
833 B
TypeScript
33 lines
833 B
TypeScript
|
import { NestFactory } from '@nestjs/core';
|
||
|
import { AppModule } from './app.module';
|
||
|
import * as dotenv from 'dotenv';
|
||
|
import * as session from 'express-session';
|
||
|
import { join } from 'path';
|
||
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
||
|
|
||
|
dotenv.config();
|
||
|
|
||
|
async function bootstrap() {
|
||
|
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
||
|
app.use(
|
||
|
session({
|
||
|
secret: process.env.SESSION_SECRET,
|
||
|
resave: true,
|
||
|
saveUninitialized: false,
|
||
|
cookie: {
|
||
|
sameSite: 'lax',
|
||
|
secure: process.env.NODE_ENV === 'production',
|
||
|
},
|
||
|
}),
|
||
|
);
|
||
|
|
||
|
app.useStaticAssets(join(__dirname, '..', 'public'), {
|
||
|
prefix: '/public/',
|
||
|
});
|
||
|
app.setBaseViewsDir(join(__dirname, '..', 'views'));
|
||
|
app.setViewEngine('pug');
|
||
|
|
||
|
await app.listen(3000);
|
||
|
}
|
||
|
bootstrap();
|