|
|
@ -1,11 +1,11 @@ |
|
|
|
import * as fs from 'fs'; |
|
|
|
import * as path from 'path'; |
|
|
|
|
|
|
|
import { environment } from '@ghostfolio/api/environments/environment'; |
|
|
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; |
|
|
|
import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config'; |
|
|
|
import { DATE_FORMAT } from '@ghostfolio/common/helper'; |
|
|
|
import { Injectable, NestMiddleware } from '@nestjs/common'; |
|
|
|
import { ConfigService } from '@nestjs/config'; |
|
|
|
import { format } from 'date-fns'; |
|
|
|
import { NextFunction, Request, Response } from 'express'; |
|
|
|
|
|
|
@ -18,18 +18,10 @@ export class FrontendMiddleware implements NestMiddleware { |
|
|
|
public indexHtmlIt = ''; |
|
|
|
public indexHtmlNl = ''; |
|
|
|
public indexHtmlPt = ''; |
|
|
|
public isProduction: boolean; |
|
|
|
|
|
|
|
public constructor( |
|
|
|
private readonly configService: ConfigService, |
|
|
|
private readonly configurationService: ConfigurationService |
|
|
|
) { |
|
|
|
const NODE_ENV = |
|
|
|
this.configService.get<'development' | 'production'>('NODE_ENV') ?? |
|
|
|
'development'; |
|
|
|
|
|
|
|
this.isProduction = NODE_ENV === 'production'; |
|
|
|
|
|
|
|
try { |
|
|
|
this.indexHtmlDe = fs.readFileSync( |
|
|
|
this.getPathOfIndexHtmlFile('de'), |
|
|
@ -100,7 +92,7 @@ export class FrontendMiddleware implements NestMiddleware { |
|
|
|
if ( |
|
|
|
request.path.startsWith('/api/') || |
|
|
|
this.isFileRequest(request.url) || |
|
|
|
!this.isProduction |
|
|
|
!environment.production |
|
|
|
) { |
|
|
|
// Skip
|
|
|
|
next(); |
|
|
|