1.0.1 • Published 7 years ago

package-settings v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

package-settings

Very simple package that manages your settings from the package.json file. Lets you keep everything in a single place. Obviously you don't need much to add some settings to the package.json file but this module loads the settings from the json automatically and also the files that you include in the settings, like certificates. You are free to specify whatever settings you need, it looks recursively for files.

NOTE 1: files are loaded sync, so don't load gigantic files or you will be blocking the event loop. The lookup for files is a recursive function. To my knowledge there is no tail call optimization in the V8 engine so don't nest to deep (But if you overflow the stack with your settings, you are probably doing something else wrong). Normal use cases should work just splendid.

NOTE 2: You need to specify NODE_ENV=development or something similar to match the settings.development key in the settings object.

NOTE 3: The package has no dependencies on external npm packages, just uses path and fs from the node library.

Usage

{
  "name": "Package name",
  "version": "1.0.0",
  "settings" : {
    "development" : {
      "webserver" : {
        "port" : 4443,
        "certs" : {
          "key" : "./certs/key.pem",
          "cert" : "./certs/cert.pem"
        }
      }
    },
    "production" : {
      ...
    },
    "staging" : {
      ...
    }
  },
  "scripts" : {
    "certs": "rm -rf certs && mkdir certs && openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout certs/key.pem -out certs/cert.pem"
  }
}
  • The certs will be automatically loaded and are available.
  • The scripts/certs here lets you easily create certificates (tested only on osx) by running npm run certs, just enter a couple of times and you are good to go for development.
1.0.1

7 years ago

1.0.0

7 years ago