0.4.1 • Published 6 years ago

bragg-load-config v0.4.1

Weekly downloads
628
License
MIT
Repository
github
Last release
6 years ago

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