Providing global config as an opaque token.

This commit is contained in:
William Welling
2017-03-24 16:15:01 -05:00
parent 76b1875e54
commit 99f936ff45
10 changed files with 74 additions and 27 deletions

View File

@@ -1,8 +1,10 @@
// Look in ./config folder for config
import { OpaqueToken } from '@angular/core';
const path = require('path');
import path from 'path';
let configContext = require.context("../config", false, /js$/);
let EnvConfig: any = {};
let EnvConfigFile: string;
let DefaultConfig: any = {};
@@ -29,6 +31,29 @@ try {
EnvConfig = {};
}
const GlobalConfig = Object.assign(DefaultConfig, EnvConfig);
const GLOBAL_CONFIG = new OpaqueToken('config');
export {GlobalConfig}
interface GlobalConfig {
"production": string,
"rest": {
"nameSpace": string,
"baseURL": string
},
"ui": {
"nameSpace": string,
"baseURL": string
},
"cache": {
"msToLive": number,
},
"universal": {
"shouldRehydrate": boolean
}
}
const globalConfig = {
provide: GLOBAL_CONFIG,
useValue: <GlobalConfig>Object.assign(DefaultConfig, EnvConfig)
};
export { GLOBAL_CONFIG, GlobalConfig, globalConfig}