@@ -19,29 +19,33 @@ import 'zone.js/dist/zone-node';
19
19
import 'reflect-metadata' ;
20
20
import 'rxjs' ;
21
21
22
- import * as fs from 'fs' ;
23
22
import * as pem from 'pem' ;
24
23
import * as https from 'https' ;
25
24
import * as morgan from 'morgan' ;
26
25
import * as express from 'express' ;
27
26
import * as bodyParser from 'body-parser' ;
28
27
import * as compression from 'compression' ;
28
+
29
+ import { existsSync , readFileSync } from 'fs' ;
29
30
import { join } from 'path' ;
30
31
32
+ import { APP_BASE_HREF } from '@angular/common' ;
31
33
import { enableProdMode } from '@angular/core' ;
32
- import { existsSync } from 'fs' ;
34
+
33
35
import { ngExpressEngine } from '@nguniversal/express-engine' ;
34
36
import { REQUEST , RESPONSE } from '@nguniversal/express-engine/tokens' ;
37
+
35
38
import { environment } from './src/environments/environment' ;
36
39
import { createProxyMiddleware } from 'http-proxy-middleware' ;
37
40
import { hasValue , hasNoValue } from './src/app/shared/empty.util' ;
38
- import { APP_BASE_HREF } from '@angular/common' ;
41
+
39
42
import { UIServerConfig } from './src/config/ui-server-config.interface' ;
40
43
41
44
import { ServerAppModule } from './src/main.server' ;
42
45
43
- // import { buildAppConfig } from './src/config/config.server';
44
- // import { AppConfig, APP_CONFIG } from './src/config/app-config.interface';
46
+ import { buildAppConfig } from './src/config/config.server' ;
47
+ import { AppConfig , APP_CONFIG } from './src/config/app-config.interface' ;
48
+ import { extendEnvironmentWithAppConfig } from './src/config/config.util' ;
45
49
46
50
/*
47
51
* Set path for the browser application's dist folder
@@ -54,7 +58,10 @@ const indexHtml = existsSync(join(DIST_FOLDER, 'index.html')) ? 'index.html' : '
54
58
55
59
const cookieParser = require ( 'cookie-parser' ) ;
56
60
57
- // const appConfig: AppConfig = buildAppConfig(join(DIST_FOLDER, 'assets/appConfig.json'));
61
+ const appConfig : AppConfig = buildAppConfig ( join ( DIST_FOLDER , 'assets/appConfig.json' ) ) ;
62
+
63
+ // extend environment with app config for server
64
+ extendEnvironmentWithAppConfig ( environment , appConfig ) ;
58
65
59
66
// The Express app is exported so that it can be used by serverless Functions.
60
67
export function app ( ) {
@@ -105,10 +112,10 @@ export function app() {
105
112
provide : RESPONSE ,
106
113
useValue : ( options as any ) . req . res ,
107
114
} ,
108
- // {
109
- // provide: APP_CONFIG,
110
- // useValue: appConfig
111
- // }
115
+ {
116
+ provide : APP_CONFIG ,
117
+ useValue : environment
118
+ }
112
119
]
113
120
} ) ( _ , ( options as any ) , callback )
114
121
) ;
@@ -246,14 +253,14 @@ function start() {
246
253
if ( environment . ui . ssl ) {
247
254
let serviceKey ;
248
255
try {
249
- serviceKey = fs . readFileSync ( './config/ssl/key.pem' ) ;
256
+ serviceKey = readFileSync ( './config/ssl/key.pem' ) ;
250
257
} catch ( e ) {
251
258
console . warn ( 'Service key not found at ./config/ssl/key.pem' ) ;
252
259
}
253
260
254
261
let certificate ;
255
262
try {
256
- certificate = fs . readFileSync ( './config/ssl/cert.pem' ) ;
263
+ certificate = readFileSync ( './config/ssl/cert.pem' ) ;
257
264
} catch ( e ) {
258
265
console . warn ( 'Certificate not found at ./config/ssl/key.pem' ) ;
259
266
}
0 commit comments