gcf-config
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

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

Package Sidebar

Install

npm i gcf-config

Weekly Downloads

2

Version

1.2.1

License

MIT

Unpacked Size

8.4 kB

Total Files

11

Last publish

Collaborators

  • mikesparr