https://github.com/crijke/feathers-envhelpers
Convenience functions to determine the current node environment in Feathers
https://github.com/crijke/feathers-envhelpers
feathers feathersjs
Last synced: about 2 months ago
JSON representation
Convenience functions to determine the current node environment in Feathers
- Host: GitHub
- URL: https://github.com/crijke/feathers-envhelpers
- Owner: crijke
- License: mit
- Created: 2018-06-17T15:21:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T19:02:07.000Z (about 3 years ago)
- Last Synced: 2025-09-11T23:31:28.746Z (6 months ago)
- Topics: feathers, feathersjs
- Language: JavaScript
- Homepage:
- Size: 214 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/contributing.md
- License: LICENSE
Awesome Lists containing this project
README
# feathers-envhelpers
[](https://travis-ci.org/crijke/feathers-envhelpers)
[](https://codeclimate.com/github/crijke/feathers-envhelpers)
[](https://codeclimate.com/github/crijke/feathers-envhelpers/coverage)
[](https://david-dm.org/crijke/feathers-envhelpers)
[](https://www.npmjs.com/package/feathers-envhelpers)
> 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:
````js
NODE_ENV=production
NODE_ENV=
NODE_ENV=development
````
These will cause an error to be thrown:
````js
NODE_ENV=PRODUCTION
NODE_ENV=Staging
````
## How to use
Configure the Plugin:
```js
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:
```js
if (app.isDevelopment()){
// do something in development only
}
```
## License
Copyright (c) 2018
Licensed under the [MIT license](LICENSE).