bragg-load-config

Load a config file based upon the environment

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
bragg-load-config
100.4.15 years ago5 years agoMinified + gzip package size for bragg-load-config in KB

Readme

bragg-load-config Build Status
Load a config file based upon the environment

Install

$ npm install bragg-load-config

Usage

config.json
{
	"production": {
		"FooService": "foo:v0"
	}
}

const app = require('bragg')();
const environment = require('bragg-env');
const loadConfig = require('bragg-load-config');

app.use(environment());
app.use(loadConfig('config.json'));
app.use(ctx => {
	console.log(ctx.config);
	/**
	 * {
	 *     "FooService": "foo:v0"
	 * }
	 */
});

Overrides

It's possible to override config data based upon the AWS Account ID.
{
	"_overrides": {
		"account:123456789012": {
			"FooService": "foo:v1"
		}
	},
	"production": {
		"FooService": "foo:v0"
	}
}

If the AWS Account ID matches 123456789012, it will merge that config object with the specific environment config object.

API

loadConfig(filePath, options)

filePath

Type: string
Path to the config file.

options

cwd
Type: string
Default: process.cwd()
Working directory of the config file.

Related

  • bragg - Serverless web framework for AWS λ.
  • bragg-env - Environment middleware for bragg.

License

MIT © Sam Verschueren