Giter Club home page Giter Club logo

config-env-test's Introduction

config-env-test

How to set variables with convict, and override them with env variables and npm arguments.

In config.js, the default port is 9999 and the default value of "foo" is "bar". In the start-script in package.json, the value of foo is overridden using the env-variable FOO, and the port-number is overridden with the argument port.

config.js

  httpServerPort: {
      doc     : "The port the server should bind to",
      format  : "port",
      default : 9999,
      env     : "PORT",
      arg     : "port"
  },

  foo: {
      doc: "just testing…",
      format: String,
      default: "bar",
      env: "FOO"
  }

start script

"scripts": {
  "start": "FOO=baz nodemon ./server.js --port=8888 | bunyan"
}

override-files

The environment variables can also be overridden using the development.json, production.json and local.json files. Switch between these during start-up, i.e. node server.js --env=production

fish

To modify env-variables directly using fish, start with env, i.e.: env FOO=barbaz node server.js

config-env-test's People

Contributors

vnys avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.