@nwx/cfg
A simple configuration module for Angular
Overview
@nwx/cfg attempts to streamline angular configuration while keeping it DRY.
How to install
npm install @nwx/cfg
(OR) yarn add @nwx/cfg
How to use
import { AppCfg, TargetPlatform, HttpMethod } from '@nwx/cfg';
export const environment: AppCfg = {
appName: 'Neekware',
target: TargetPlatform.web,
production: true,
rmtCfg: {
endpoint: '/api/cfg',
method: HttpMethod.get,
timeout: 3,
headers: { 'Content-Type': 'application/json' }
body: {
}
}
};
import { CfgModule } from '@nwx/cfg';
import { environment } from '../environments/environment';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
CfgModule.forRoot(environment)
],
bootstrap: [AppComponent]
})
export class AppModule {}
import { Component } from '@angular/core';
import { CfgService } from 'pkgs/cfg';
@Component({
selector: 'app-root'
})
export class AppComponent {
title = '@nwx/cfg';
options = {};
constructor(public cfg: CfgService) {
this.options = { ...this.cfg.options, ...{ pkgName: this.title } };
}
}
Running the tests
To run the tests against the current environment:
npm test cfg
License
Released under a (MIT) license.