Skip to content

Commit

Permalink
feat: create API host helper and environment-specific API host strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepinho committed Apr 23, 2017
1 parent 2d1d0c7 commit db4f353
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { APIHostProvider } from './helpers/api-host';
import { AppComponent } from './app.component';
import { FaceComponent } from './face/face.component';
import { TweetComponent } from './tweet/tweet.component';
Expand All @@ -24,6 +25,7 @@ import { SvgComponent } from './svg/svg.component';
HttpModule,
],
providers: [
APIHostProvider,
TwitterService,
],
bootstrap: [AppComponent]
Expand Down
5 changes: 5 additions & 0 deletions src/app/helpers/api-host.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { OpaqueToken } from '@angular/core';
import { environment } from '../../environments/environment';

export const APIHost = new OpaqueToken('APIHost');
export const APIHostProvider = { provide: APIHost, useValue: environment.apiHost };
3 changes: 2 additions & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const environment = {
production: true
apiHost: 'http://api.trumpymctweetface.com',
production: true,
};
3 changes: 2 additions & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
// The list of which env maps to which file can be found in `.angular-cli.json`.

export const environment = {
production: false
apiHost: 'http://localhost:5000',
production: false,
};

0 comments on commit db4f353

Please sign in to comment.