LocChat/server/main.ts

29 lines
845 B
TypeScript
Raw Normal View History

2021-11-16 21:14:46 -05:00
import './env';
import * as fs from 'fs';
import { NestFactory } from '@nestjs/core';
import { join } from 'path';
import { NestExpressApplication } from '@nestjs/platform-express';
2021-11-20 20:18:58 -05:00
import * as cookieParser from 'cookie-parser';
import { AppModule } from './app.module';
2021-11-16 21:14:46 -05:00
async function bootstrap() {
let httpsOptions;
if (process.env.NODE_ENV === 'development') {
httpsOptions = {
key: fs.readFileSync('./private-key.pem'),
cert: fs.readFileSync('./public-cert.pem'),
};
}
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
httpsOptions,
2021-11-20 20:18:58 -05:00
logger: ['verbose'],
2021-11-16 21:14:46 -05:00
});
2021-11-20 20:18:58 -05:00
app.use(cookieParser());
2021-11-16 21:14:46 -05:00
app.useStaticAssets(join(__dirname, '..', 'static'));
2021-11-23 16:04:12 -05:00
app.setBaseViewsDir(join(__dirname, '..', 'views'));
2021-11-16 21:14:46 -05:00
app.setViewEngine('hbs');
await app.listen(process.env.PORT);
}
bootstrap();