@bondxge/config

Angular 6 config file, read config on startup

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
Minified + gzip package size for @bondxge/config in KB

Readme

@BondxgeConfig

First, install it.

$ npm install @bondxge/config

Then add config.json file in assets.

Then, import it into your @NgModule:


import { ConfigModule } from '@bondxge/config';

imports : [
    ConfigModule.forRoot('assets/config.json'),
]

Then, use it in your component:

import { CONFIG } from '@lbge/config'; CONFIG.find('yourKey');


import { Injectable } from '@angular/core';
import { HttpRequest, HttpInterceptor, HttpHandler, HttpEvent, HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { CONFIG } from '@bondxge/config';
import { tap } from 'rxjs/operators';

@Injectable()
export class BaseUrlInterceptor implements HttpInterceptor {

    constructor() {
    }

    intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
        req = req.clone({
            url: CONFIG.find<string>('apiUrl') + req.url
        });
        return next.handle(req);
    }
}

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.