-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from millenr/A2-2036
A2-2036 : Runtime configurations
- Loading branch information
Showing
28 changed files
with
217 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# Check for WRITE_CONFIG env variable | ||
if [ "${WRITE_CONFIG}" != "true" ]; then | ||
echo "WRITE_CONFIG is not set to 'true'. Skipping JSON configuration." | ||
else | ||
echo "Creating JSON configuration from environment variables." | ||
# Read environment variables | ||
ENVIRONMENT="${ENVIRONMENT:?Error: ENVIRONMENT environment variable not set}" | ||
DATA_URL="${DATA_URL:?Error: DATA_URL environment variable not set}" | ||
API_SWAGGER_URL="${API_SWAGGER_URL:?Error: API_SWAGGER_URL environment variable not set}" | ||
|
||
# Write to config.json file | ||
cat > /usr/share/nginx/html/assets/config.json <<EOF | ||
{ | ||
"ENVIRONMENT": "$ENVIRONMENT", | ||
"DATA_URL": "$DATA_URL", | ||
"API_SWAGGER_URL": "$API_SWAGGER_URL" | ||
} | ||
EOF | ||
fi | ||
|
||
# Start NGINX | ||
exec nginx -g "daemon off;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; | ||
import { ConfigService } from './config.service'; | ||
|
||
describe('ConfigService', () => { | ||
let service: ConfigService; | ||
let httpMock: HttpTestingController; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [HttpClientTestingModule], | ||
providers: [ConfigService] | ||
}); | ||
|
||
service = TestBed.inject(ConfigService); | ||
httpMock = TestBed.inject(HttpTestingController); | ||
}); | ||
|
||
afterEach(() => { | ||
httpMock.verify(); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// src/app/config.service.ts | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ConfigService { | ||
private config: any; | ||
|
||
constructor(private http: HttpClient) {} | ||
|
||
loadConfig(): Promise<any> { | ||
return this.http.get('/assets/config.json').toPromise().then((config) => { | ||
this.config = config; | ||
}); | ||
} | ||
|
||
get(key: string) { | ||
return this.config[key]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.