gcf-config
v1.2.1
Published
Reusable configuration module using ENV vars for cloud function apps
Downloads
4
Maintainers
Readme
GCF Config
This is a reusable configuration module to leverage ENV vars for app configuration inspired by https://12factor.net/config
Installation
npm install gcf-config
yarn add gcf-config
Usage
Node
const conf = require("gcf-config");
// instantiate: assume ENV var API_KEY exists
const config = new conf.Config({
apiKey: "API_KEY"
});
// access
const baseUrl = `https://api.google.com`;
const url = `${baseUrl}?api_key=${config.get("apiKey")}`;
console.log(`URL: ${url}`);
Typescript
import {Config, IConfig} from "gcf-config";
// instantiate: assume ENV var API_KEY exists
const config: IConfig<string> = new Config({
apiKey: "API_KEY"
});
// access
const baseUrl: string = `https://api.google.com`;
const url: string = `${baseUrl}?api_key=${config.get("apiKey")}`;
Testing
npm test
npm run coverage
Build (compiles Typescript to JS)
npm run build