From cba40b6aff598e821199c186c5f1795e5252bab9 Mon Sep 17 00:00:00 2001 From: Joseph Ditton Date: Tue, 16 Nov 2021 19:14:46 -0700 Subject: separate client and server apps --- server/main.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 server/main.ts (limited to 'server/main.ts') diff --git a/server/main.ts b/server/main.ts new file mode 100644 index 0000000..2ed7d94 --- /dev/null +++ b/server/main.ts @@ -0,0 +1,26 @@ +import './env'; +import * as fs from 'fs'; +import { NestFactory } from '@nestjs/core'; +import { join } from 'path'; +import * as morgan from 'morgan'; +import { AppModule } from './app.module'; +import { NestExpressApplication } from '@nestjs/platform-express'; + +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(AppModule, { + httpsOptions, + }); + app.use(morgan('tiny')); + app.useStaticAssets(join(__dirname, '..', 'static')); + app.setBaseViewsDir(join(__dirname, '../', 'views')); + app.setViewEngine('hbs'); + await app.listen(process.env.PORT); +} +bootstrap(); -- cgit v1.2.3-70-g09d2