Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mikesparr/gcf-config

Configuration using ENV variables within Google Cloud Functions described in https://12factor.net/config
https://github.com/mikesparr/gcf-config

12factor cloud-functions configuration environment-variables

Last synced: about 6 hours ago
JSON representation

Configuration using ENV variables within Google Cloud Functions described in https://12factor.net/config

Awesome Lists containing this project

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
``` javascript
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
``` typescript
import {Config, IConfig} from "gcf-config";

// instantiate: assume ENV var API_KEY exists
const config: IConfig = 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
```