1.0.1 • Published 5 years ago

envster v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Envster

Environment variables made easier and more flexible than ever!

This package helps you manage your environment variables and secrets, while also being very flexible and allowing you to customize this process if desired.

Usage

Envster should be configured as early on in your application as possible, as to prevent any mishaps.

const Envster = require('envster');

// These are the default settings: EVERYTHING is optional!
const env = new Envster({
	envPath: process.cwd(), // Directory of the env file
	envName: '.env', // Name and extension of the env file
	separator: '=', // Key-value separator
	populateProcess: true, // Will push all key-values onto "process.env" if true
	commentDelimiter: '#', // One-line comment delimiter
	enableDebug: false, // Debug logs
}).init();

console.log(env);

ExampleService.listen(process.env.EXAMPLE_SERVICE_PORT);

API

Envster by default exports a class. This class takes in a single object parameter, where you can define your settings, as shown above. This class has functionality for parsing and dumping internally, but you will most certainly only have to use the "init" function.

init

new Envster().init();
new Envster(options).init();

This initializes Envster, which will in turn parse the env file, dump it to "process.env" (if enabled). It returns an object containing every single key-value pair that has been defined within the env file.

Examples

More examples of Envster in action can be found in the repository under "examples".

Todo

  • Write JSDoc
  • Write TypeScript typings
  • Optimize
  • Review and finalize