8000 GitHub - jon-sully/contextual-env
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Dec 30, 2020. It is now read-only.

jon-sully/contextual-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

contextual-env

This package is a thin wrapper function intended to inject the value of an already-set CONTEXT environment variable into the environment variable argument given to the function.

This is best explained in https://jonsully.net/blog/configuring-environment-variables-for-all-netlify-environments/

Usage

This package is particularly well-suited for Netlify Functions, where CONTEXT is set for you. This example shows a Function that will pull the correct <CONTEXT>_API_KEY value depending on which Netlify environment it's running in:

import { contextualEnv } from 'contextual-env'

exports.handler = async _ => {
  return {
    statusCode: 200,
    body: JSON.stringify({
      status: contextualEnvVar('API_KEY'),
      context: process.env.CONTEXT
    })
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published
0