0.3.0 • Published 5 years ago

@nodearch/config v0.3.0

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
5 years ago

NodeArch Config

Usage

config file example

server.json

[
  {
    "key": "host",
    "value": "http://localhost:3000",
    "type": "string",
    "env": "HOST",
    "required": true
  },
  {
    "key": "port",
    "value": 3000,
    "env": "PORT"
  }
]

main.ts

import { createInstance, IEnv, config } from '@nodearch/config';
import * as path from 'path' ;

async function main () {
  // config folder path
  const configPath = path.join(__dirname, '..', 'config');
  // environment to use
  const env = process.env.NODE_ENV || 'development';
  // environment data object i.e ( environment variables )
  const envVars: IEnv = <IEnv>process.env;
  // create config instance
  await createInstance(configPath, env, envVars);

  console.log("host", config.get("server.host") );
  console.log("port", config.get("server.port") );
}

main()
  .catch(err => {
    console.log(err.message);
    process.exit(1);
  });
0.3.0

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago