Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/refactor env variables access (#1116)
Thomas Kaul148f6f876295
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4b20e43228..72e829ab59 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Improved the performance of data provider requests by introducing a maximum number of symbols per request (chunk size)- Changed the log level settings+- Refactored the access of the environment variables in the bootstrap function (api)## 1.175.0 - 29.07.2022diff --git a/apps/api/src/main.ts b/apps/api/src/main.tsindex fd8237cd29..b8bfb81de2 100644--- a/apps/api/src/main.ts+++ b/apps/api/src/main.ts@@ -1,13 +1,21 @@import { Logger, ValidationPipe, VersioningType } from '@nestjs/common';+import { ConfigService } from '@nestjs/config';import { NestFactory } from '@nestjs/core';import { AppModule } from './app/app.module';import { environment } from './environments/environment';async function bootstrap() {+ const configApp = await NestFactory.create(AppModule);+ const configService = configApp.get<ConfigService>(ConfigService);++ const NODE_ENV =+ configService.get<'development' | 'production'>('NODE_ENV') ??+ 'development';+const app = await NestFactory.create(AppModule, {logger:- process.env.NODE_ENV === 'production'+ NODE_ENV === 'production'? ['error', 'log', 'warn']: ['debug', 'error', 'log', 'verbose', 'warn']});@@ -25,11 +33,11 @@ async function bootstrap() {}));- const host = process.env.HOST || '0.0.0.0';- const port = process.env.PORT || 3333;- await app.listen(port, host, () => {+ const HOST = configService.get<string>('HOST') || '0.0.0.0';+ const PORT = configService.get<number>('PORT') || 3333;+ await app.listen(PORT, HOST, () => {logLogo();- Logger.log(`Listening at http://${host}:${port}`);+ Logger.log(`Listening at http://${HOST}:${PORT}`);Logger.log('');});}