summaryrefslogtreecommitdiff
path: root/server/main.ts
diff options
context:
space:
mode:
authorJoseph Ditton <jditton.atomic@gmail.com>2021-11-16 19:14:46 -0700
committerJoseph Ditton <jditton.atomic@gmail.com>2021-11-16 19:14:46 -0700
commitcba40b6aff598e821199c186c5f1795e5252bab9 (patch)
treea5e4ad3bae238c3921e10956f21f84ca352c7d6d /server/main.ts
parente5f684001370d6f6348fd26f97bc26c765deb934 (diff)
downloadlocchat-cba40b6aff598e821199c186c5f1795e5252bab9.tar.gz
locchat-cba40b6aff598e821199c186c5f1795e5252bab9.zip
separate client and server apps
Diffstat (limited to 'server/main.ts')
-rw-r--r--server/main.ts26
1 files changed, 26 insertions, 0 deletions
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<NestExpressApplication>(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();