summaryrefslogtreecommitdiff
path: root/server/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/main.ts')
-rw-r--r--server/main.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/server/main.ts b/server/main.ts
index b4f319b..a8dc0ae 100644
--- a/server/main.ts
+++ b/server/main.ts
@@ -1,14 +1,16 @@
import './env';
import * as fs from 'fs';
import { NestFactory } from '@nestjs/core';
+import { Logger } from '@nestjs/common';
import { join } from 'path';
import { NestExpressApplication } from '@nestjs/platform-express';
import * as cookieParser from 'cookie-parser';
import { AppModule } from './app.module';
+import * as morgan from 'morgan';
async function bootstrap() {
let httpsOptions;
- if (process.env.NODE_ENV === 'development') {
+ if (process.env.USE_SSL === 'true') {
httpsOptions = {
key: fs.readFileSync('./private-key.pem'),
cert: fs.readFileSync('./public-cert.pem'),
@@ -18,11 +20,18 @@ async function bootstrap() {
httpsOptions,
logger: ['verbose'],
});
-
app.use(cookieParser());
app.useStaticAssets(join(__dirname, '..', 'static'));
app.setBaseViewsDir(join(__dirname, '..', 'views'));
app.setViewEngine('hbs');
+ const logger = new Logger('Request');
+ app.use(
+ morgan('tiny', {
+ stream: {
+ write: (message) => logger.log(message.replace('\n', '')),
+ },
+ }),
+ );
await app.listen(process.env.PORT);
}
bootstrap();