Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

starry-comet/comet-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

comet-config

Build Status npm NSP Status Codacy Badge

Roles

Use a namespace to join environment variables with configuration file and expose a configuration object.

Engine

Any configuration property can be set in environement variable or config file, an environment overrride all files. A environment property is translate from NAMESPACE_MY_VAR to myVar in Configuration object

Utils

You can add additional path to look for config files. the symbol you must provide is extraConfigPaths, it's an array of string.

Config file example

module.exports = { 
  key: 'value',
  test: true, 
  ab: 'test' 
}

Usage

process.env['TEMOC_ENVIRONEMENT_PROPERTY'] = 'property-value'

import { Inject, Injectable, bootstrap } from 'comet-ioc'
import { Configuration, namespace } from "comet-config";

@Injectable()
export class App {
  constructor(@Inject(Configuration) public conf: Configuration) { }
}

app = bootstrap(App, {
  declarations: [
    Configuration
  ],
  constants: [{
    provide: namespace,
    useValue: 'temoc'
  }]
})

console.log( app.conf.props.environementProperty ) // display: property-value