bondx-config

0.0.2 • Public • Published

@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);
    }
}

/bondx-config/

    Package Sidebar

    Install

    npm i bondx-config

    Weekly Downloads

    2

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    8.06 kB

    Total Files

    14

    Last publish

    Collaborators

    • gabina