From c91973b1850a52383a4562c042ffc54a7c8427bc Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Sat, 15 Jun 2024 00:37:12 +0300 Subject: [PATCH] refactor: use other way to save env --- angular.json | 8 +++++++- src/api/api.service.ts | 2 +- .../environment.development.ts} | 5 ++--- src/environments/environment.ts | 5 +++++ src/pages/setup/welcome/welcome.component.ts | 2 +- tsconfig.json | 1 + 6 files changed, 17 insertions(+), 6 deletions(-) rename src/{config/environment.ts => environments/environment.development.ts} (69%) create mode 100644 src/environments/environment.ts diff --git a/angular.json b/angular.json index 9d2027c..c09a451 100644 --- a/angular.json +++ b/angular.json @@ -49,7 +49,13 @@ "development": { "optimization": false, "extractLicenses": false, - "sourceMap": true + "sourceMap": true, + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.development.ts" + } + ] } }, "defaultConfiguration": "production" diff --git a/src/api/api.service.ts b/src/api/api.service.ts index fc6b5db..4717279 100644 --- a/src/api/api.service.ts +++ b/src/api/api.service.ts @@ -1,7 +1,7 @@ import {catchError, mergeMap, Observable, retryWhen, timer} from "rxjs"; import {HttpClient, HttpErrorResponse} from "@angular/common/http"; import {NotifyColor, OpenNotifyService} from "@service/open-notify.service"; -import {environment} from "@/config/environment"; +import {environment} from "@environment"; import {Router} from "@angular/router"; import {Injectable} from "@angular/core"; diff --git a/src/config/environment.ts b/src/environments/environment.development.ts similarity index 69% rename from src/config/environment.ts rename to src/environments/environment.development.ts index 755c7f8..c62fde0 100644 --- a/src/config/environment.ts +++ b/src/environments/environment.development.ts @@ -1,6 +1,5 @@ export const environment = { apiUrl: 'http://localhost:5269/api/', - production: false, - maxRetry: 3, + maxRetry: 5, retryDelay: 1500 -} +}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts new file mode 100644 index 0000000..d2842ae --- /dev/null +++ b/src/environments/environment.ts @@ -0,0 +1,5 @@ +export const environment = { + apiUrl: '', + maxRetry: 3, + retryDelay: 1500 +}; diff --git a/src/pages/setup/welcome/welcome.component.ts b/src/pages/setup/welcome/welcome.component.ts index 24675a4..fab5155 100644 --- a/src/pages/setup/welcome/welcome.component.ts +++ b/src/pages/setup/welcome/welcome.component.ts @@ -6,7 +6,7 @@ import {MatInput} from "@angular/material/input"; import {AsyncPipe} from "@angular/common"; import {FormControl, ReactiveFormsModule, Validators} from "@angular/forms"; import SetupService from "@api/v1/setup.service"; -import {environment} from "@/config/environment"; +import {environment} from "@environment"; import {AvailableVersion} from "@api/api.service"; @Component({ diff --git a/tsconfig.json b/tsconfig.json index 3aaf0da..1a7aa8c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,6 +37,7 @@ "./src/shared/requests/*", "./src/api/*" ], + "@environment": ["./src/environments/environment.ts"], "@/*": [ "./src/*" ]