src/main.ts   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 45
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 39
mnd 0
bc 0
fnc 1
dl 0
loc 45
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A main.ts ➔ bootstrap 0 30 1
1
import * as path from 'path';
2
import { NestFactory } from '@nestjs/core';
3
import { ValidationPipe } from '@nestjs/common';
4
import * as helmet from 'helmet';
5
import * as cookieParser from 'cookie-parser';
6
import { NestExpressApplication } from '@nestjs/platform-express';
7
import { AppModule } from './app.module';
8
import dataSource from './datasource';
9
import { ITemplates } from './Infrastructure/Templates/ITemplates';
10
import { flashMessages } from './Infrastructure/Templates/FlashMessages';
11
import { useSession } from './Infrastructure/Security/ExpressSession';
12
13
async function bootstrap() {
14
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
15
16
  app.use(helmet());
17
  app.use(cookieParser());
18
  app.useGlobalPipes(
19
    new ValidationPipe({
20
      transform: true,
21
      transformOptions: { enableImplicitConversion: true }
22
    })
23
  );
24
25
  await useSession(app, dataSource);
26
27
  // Scalingo runs apps behind a reverse proxy
28
  app.set('trust proxy', 1);
29
30
  const assetsDir = path.join(__dirname, '..', 'public');
31
  app.useStaticAssets(assetsDir);
32
33
  const viewsDir = path.join(__dirname, '..', 'templates');
34
  app.setBaseViewsDir(viewsDir);
35
36
  const templates: ITemplates = app.get('ITemplates');
37
  templates.registerViewEngine(app, '');
38
39
  app.use(flashMessages());
40
41
  await app.listen(+(process.env.PORT || 3000), '0.0.0.0');
42
}
43
44
bootstrap();
45