Skip to content

Commit

Permalink
feat(envConfig): add static type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
mgechev committed Aug 18, 2016
1 parent 889d437 commit 55c7359
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/client/app/shared/config/env.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Feel free to extend this interface
// depending on your app specific config.
export interface IConfig {
API: string;
export interface EnvConfig {
API?: string;
ENV?: string;
}

export const Config: IConfig = JSON.parse('<%= ENV_CONFIG %>');
export const Config: EnvConfig = JSON.parse('<%= ENV_CONFIG %>');

6 changes: 5 additions & 1 deletion tools/env/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export = {
import {EnvConfig} from './env-config.interface';

const BaseConfig: EnvConfig = {
// Sample API url
API: 'https://demo.com'
};

export = BaseConfig;

6 changes: 5 additions & 1 deletion tools/env/dev.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export = {
import {EnvConfig} from './env-config.interface';

const DevConfig: EnvConfig = {
ENV: 'DEV'
};

export = DevConfig;

2 changes: 2 additions & 0 deletions tools/env/env-config.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {EnvConfig} from '../../src/client/app/shared/config/env.config';

6 changes: 5 additions & 1 deletion tools/env/prod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export = {
import {EnvConfig} from './env-config.interface';

const ProdConfig: EnvConfig = {
ENV: 'PROD'
};

export = ProdConfig;

0 comments on commit 55c7359

Please sign in to comment.