Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enviro

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enviro

env ===

  • 0.2.2
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

env

Env is a Node and client-side ~60 LOC library to manage what environment your code is running in, and let you override the environment for parts of the system.

Usage

On Node
Env = require('enviro')

Env.get('api') # Will return local, development, or production
Env.getInternal('api') # Will return local, qa, or prod

# Gets it's env from env vars, first would look to API_ENV, then NODE_ENV
On The Frontend
hubspot.require ['enviro'], (Env) ->

  Env.get('usage_tracking')
  
  # Set with window.USAGE_TRACKING_ENV or localStorage.USAGE_TRACKING_ENV
  # If neither is defined, it will use hubspot.server.env
Functions

get(serviceName, [default]) - returns 'development' or 'production' to let you know which servers serviceName should be talking to

getShort(serviceName, [default]) - returns 'local', 'qa' or 'prod', otherwise the same as get

deployed(serviceName) - Returns boolean based on whether serviceName should be considered actually deployed

Deployed

By convention, the environments defined by specific names refer to which server you should be communicating with, not which environment this process is actually in. The special deployed env can be used to get the actual environment the process is running in.

Enviro also provides the deployed function which will return true if the service is deployed.

Manipulating Things

You can override what apis your software talks to, and whether it thinks it's deployed.

  • The env var / localstorage key API_ENV will, for example, change what is returned by Env.get('api')
  • The env var / localstorage key GAMERA_DEPLOYED will, for example, change what is returned by Env.deployed('gamera')
  • A request for Env.get('api.gamera') will first look to API_ENV, then GAMERA_ENV

FAQs

Package last updated on 07 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc