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
let baseUrl: string = this.configService.get(api).baseUrl; |
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
@Injectable() | |
export class ConfigService { | |
private config: Object | |
private env: Object | |
constructor(private http: Http) {} | |
/** | |
* Loads the environment config file first. Reads the environment |
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
{ | |
"api": { | |
"baseUrl": "/api" | |
}, | |
"debugging": true | |
} |
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
"scripts": { | |
"start": "npm run pre-start & ng serve", | |
"pre-start": "node hooks/pre-start.js", | |
"pre-build": "node hooks/pre-build.js", | |
"my-custom-build": "npm run pre-build & ng build --prod --aot" | |
} |
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
{ "env": "development" } |
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
function setEnvironment(configPath, environment) { | |
fs.writeJson(configPath, {env: environment}, | |
function (res) { | |
console.log('Environment variable set to ' + environment) | |
} | |
); | |
} | |
// Set environment variable to "production" | |
setEnvironment('./src/config/env.json', 'production'); |
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
const formDataMediaType = { | |
'Accept': 'application/json, text/plain, */*', | |
'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' | |
}; | |
@POST("/products") | |
@Produces(MediaType.FORM_DATA) | |
@Headers(formDataMediaType) | |
@Adapter(CustomService.customAdapter) |
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
@Injectable() | |
@DefaultHeaders({ | |
'Accept': 'application/json', | |
'Content-Type': 'application/json' | |
}) | |
export class ProductsApiClient extends HttpService { | |
@PUT("/products/{id}") | |
public updateProductById(@Path("id") id: number, @Body product: Product): Observable<any> { return null; }; | |
} |
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
@Effect() | |
doLogin$: Observable<Action> = this.actions$ | |
.ofType(actions.ActionTypes.DO_LOGIN) | |
.map((action: actions.DoLoginAction) => action.payload) | |
.switchMap(state => { | |
return this.authApiClient.login(state) | |
.map(user => new actions.DoLoginSuccessAction(new User(user))) | |
.catch(error => of(new actions.DoLoginFailAction())); | |
}); |
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
export interface State { | |
products: fromProducts.State; | |
login: fromAuth.State; | |
} | |
const reducers = { | |
products: fromProducts.reducer, | |
login: fromAuth.reducer | |
}; |