@aofl/server-environment

Helps determine dev, stage, prod environments based on hostname

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
251Jun 15, 2021Aug 23, 2018Minified + gzip package size for @aofl/server-environment in KB

Readme

@aofl/server-environment

Helps determine dev, stage, prod environments based on hostname.

Api Documentation


Examples


Installation

npm i -S @aofl/server-environment

Usage

import {getServerEnvironment, environmentTypeEnumerate} from '@aofl/server-environment';

const env = getServerEnvironment(/localhost/, /^stage\./);
const debugMode = (env === environmentTypeEnumerate.DEV);

Methods

getServerEnvironment

Takes a devRegex and a stageRegex and tests them against hostname. Returns 'production' if the regexes do not capture any results from hostname.

Name Type Description
devRegex RegExp
stageRegex RegEx

Constants

environmentTypeEnumerate

Key Value
DEV development
STAGE stage
PROD production

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.