0.6.2 • Published 5 years ago

feathers-envhelpers v0.6.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

feathers-envhelpers

Build Status Code Climate Test Coverage Dependency Status Download Status

Convenience functions to determine the current node environment in Feathers

Installation

npm install feathers-envhelpers --save

API

This plugin adds the following methods to the app object:

app.isDevelopment()

returns true if

  • NODE_ENV is set to 'development'
  • NOVE_ENV is not set or empty

app.isProduction()

returns true if NODE_ENV is set to 'production'

app.isEnv(name)

returns true if Feathers is running in environment with name 'name', eg. app.isEnv('staging')

app.getEnv()

returns process.env.NODE_ENV or 'development' if no value has been set

Environment validation

The plugin validates the value of NODE_ENV to ensure it is written in lowercase and throws an Error otherwise.

These values will pass:

NODE_ENV=production
NODE_ENV=
NODE_ENV=development

These will cause an error to be thrown:

NODE_ENV=PRODUCTION
NODE_ENV=Staging

How to use

Configure the Plugin:

const feathers = require('@feathersjs/feathers');
const envHelpers = require('feathers-envhelpers');

// Initialize the application
const app = feathers();

// Initialize the plugin
app.configure(envHelpers());

Then in your application code:

if (app.isDevelopment()){
 // do something in development only
}

License

Copyright (c) 2018

Licensed under the MIT license.

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.2.0

6 years ago

0.3.0

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago

0.0.1-0

6 years ago

0.0.1-2

6 years ago