Make NODE_ENV optional in production
* Make NODE_ENV optional * Update changelog --------- Co-authored-by: Thomas <4159106+dtslvr@users.noreply.github.com>
This commit is contained in:
parent
1e42d6bffa
commit
62c93ad99d
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Harmonized the axis style of charts
|
- Harmonized the axis style of charts
|
||||||
|
- Made setting `NODE_ENV: production` optional (to avoid `ENOENT: no such file or directory` errors on startup)
|
||||||
- Removed the environment variable `ENABLE_FEATURE_CUSTOM_SYMBOLS`
|
- Removed the environment variable `ENABLE_FEATURE_CUSTOM_SYMBOLS`
|
||||||
|
|
||||||
## 1.242.0 - 2023-03-04
|
## 1.242.0 - 2023-03-04
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
|
import { environment } from '@ghostfolio/api/environments/environment';
|
||||||
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
|
||||||
import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config';
|
import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config';
|
||||||
import { DATE_FORMAT } from '@ghostfolio/common/helper';
|
import { DATE_FORMAT } from '@ghostfolio/common/helper';
|
||||||
import { Injectable, NestMiddleware } from '@nestjs/common';
|
import { Injectable, NestMiddleware } from '@nestjs/common';
|
||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { NextFunction, Request, Response } from 'express';
|
import { NextFunction, Request, Response } from 'express';
|
||||||
|
|
||||||
@ -18,18 +18,10 @@ export class FrontendMiddleware implements NestMiddleware {
|
|||||||
public indexHtmlIt = '';
|
public indexHtmlIt = '';
|
||||||
public indexHtmlNl = '';
|
public indexHtmlNl = '';
|
||||||
public indexHtmlPt = '';
|
public indexHtmlPt = '';
|
||||||
public isProduction: boolean;
|
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
private readonly configService: ConfigService,
|
|
||||||
private readonly configurationService: ConfigurationService
|
private readonly configurationService: ConfigurationService
|
||||||
) {
|
) {
|
||||||
const NODE_ENV =
|
|
||||||
this.configService.get<'development' | 'production'>('NODE_ENV') ??
|
|
||||||
'development';
|
|
||||||
|
|
||||||
this.isProduction = NODE_ENV === 'production';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.indexHtmlDe = fs.readFileSync(
|
this.indexHtmlDe = fs.readFileSync(
|
||||||
this.getPathOfIndexHtmlFile('de'),
|
this.getPathOfIndexHtmlFile('de'),
|
||||||
@ -100,7 +92,7 @@ export class FrontendMiddleware implements NestMiddleware {
|
|||||||
if (
|
if (
|
||||||
request.path.startsWith('/api/') ||
|
request.path.startsWith('/api/') ||
|
||||||
this.isFileRequest(request.url) ||
|
this.isFileRequest(request.url) ||
|
||||||
!this.isProduction
|
!environment.production
|
||||||
) {
|
) {
|
||||||
// Skip
|
// Skip
|
||||||
next();
|
next();
|
||||||
|
@ -10,15 +10,10 @@ async function bootstrap() {
|
|||||||
const configApp = await NestFactory.create(AppModule);
|
const configApp = await NestFactory.create(AppModule);
|
||||||
const configService = configApp.get<ConfigService>(ConfigService);
|
const configService = configApp.get<ConfigService>(ConfigService);
|
||||||
|
|
||||||
const NODE_ENV =
|
|
||||||
configService.get<'development' | 'production'>('NODE_ENV') ??
|
|
||||||
'development';
|
|
||||||
|
|
||||||
const app = await NestFactory.create(AppModule, {
|
const app = await NestFactory.create(AppModule, {
|
||||||
logger:
|
logger: environment.production
|
||||||
NODE_ENV === 'production'
|
? ['error', 'log', 'warn']
|
||||||
? ['error', 'log', 'warn']
|
: ['debug', 'error', 'log', 'verbose', 'warn']
|
||||||
: ['debug', 'error', 'log', 'verbose', 'warn']
|
|
||||||
});
|
});
|
||||||
app.enableCors();
|
app.enableCors();
|
||||||
app.enableVersioning({
|
app.enableVersioning({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user