UNPKG

@springbuck/ng-reed

Version:

Blog front-end to https://github.com/isaiahiroko/laravel-reed

59 lines (54 loc) 1.91 kB
import { Injectable, Inject, InjectionToken, Optional } from "@angular/core"; export interface NgReedConfigContract{ } const BASE_URL = 'http://127.0.0.1:8000/api'; export const NGREED_CONFIG_DEFAULT_VALUES: NgReedConfigContract = { agent : { key : 'springbok', token : '7b839edbd62d1bb025782785be46fa1ee2586a16814684b256360e42d9ac5a56' }, headers : [ { key : 'Content-Type', value : 'application/x-www-form-urlencoded' }, { key : 'Accept', value : 'application/vnd.commodity.v1+json' } ], urls : { base: BASE_URL, version : BASE_URL + '/version', user : { index: BASE_URL + '/user', token: BASE_URL + '/user/token', reset: BASE_URL + '/user/reset' }, client : { index: BASE_URL + '/client', token: BASE_URL + '/client/token', reset: BASE_URL + '/client/reset' }, proprietor : { index: BASE_URL + '/proprietor', token: BASE_URL + '/proprietor/token', reset: BASE_URL + '/proprietor/reset' }, bot : { index: BASE_URL + '/springbok' } } }; export const NGREED_CONFIG_DEFAULT = new InjectionToken<NgReedConfigContract>('ng-reed.config.default'); export const NGREED_CONFIG = new InjectionToken<NgReedConfigContract>('ng-reed.config.custom'); @Injectable() export class NgReedConfig implements NgReedConfigContract{ config: NgReedConfigContract; //? constructor( @Inject(NGREED_CONFIG_DEFAULT) private defaultConfig: NgReedConfigContract, @Optional() @Inject(NGREED_CONFIG) private customConfig: NgReedConfigContract ){ this.config = Object.assign({}, defaultConfig, (customConfig) ? customConfig : {}); } }