0.0.2 • Published 3 years ago

yag-env v0.0.2

Weekly downloads
2
License
BSD-3-Clause
Repository
-
Last release
3 years ago

yag-env

Version 0.0.1, Copyright (c) 2016, Yassel Avila Gil

What is this?

Prepares the data defined via 'process.env' to be used in web applications or node packages.

License

BSD 3 Clause

Documentation

Environment definition

You can define the environment in the following ways:

  • Production (default):

    • Defining NODE_ENV or ENV: NODE_ENV=production or ENV=prod
    • Using flags PRODUCTION=true, PRODUCTION=yes or PROD=1
  • Staging:

    • Defining NODE_ENV or ENV: NODE_ENV=staging or ENV=stg
    • Using flags STAGING=true, STAGING=yes or STG=1
  • Testing:

    • Defining NODE_ENV or ENV: NODE_ENV=testing or ENV=stg
    • Using flags TESTING=true, TESTING=yes or TEST=1
  • Development:

    • Defining NODE_ENV or ENV: NODE_ENV=development or ENV=dev
    • Using flags DEVELOPMENT=true, DEVEL=yes or DEV=1

Example

The following will define the development environment and will export some extra variables:

NODE_ENV=development ONE=1 TWO=2 OTHER=other EXPORTS=ONE,TWO node node-test.js

API

JavaScript:

var env = require('yag-env');

console.log(env.ENV); // 'development'
console.log(env.isProduction); // FALSE
console.log(env.isStaging); // FALSE
console.log(env.isTesting); // FALSE
console.log(env.isDevelopment); // TRUE
console.log(env.exported); // {ONE, TWO}

TypeScript:

import {default as env} from 'yag-env';

console.log(env.ENV); // 'development'
console.log(env.isProduction); // FALSE
console.log(env.isStaging); // FALSE
console.log(env.isTesting); // FALSE
console.log(env.isDevelopment); // TRUE
console.log(env.exported); // {ONE, TWO}
0.0.2

3 years ago

0.0.1

8 years ago