@sharyn/env
# Deprecated
Last updated 7 days ago by sharyn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @sharyn/env 
SYNC missed versions from official npm registry.

???? @sharyn/env

Deprecated

Use envalid instead. Example:

const envalid = require('envalid')
const pick = require('lodash.pick')
const either = require('@sharyn/util.either')
const swit = require('@sharyn/util.swit')

const { email, bool, port, str } = envalid

const varDefs = {
  STAGE: str({ choices: ['dev', 'local-prod', 'staging', 'prod'] }),
  TRUE: bool(),
  EMAIL: email({ desc: 'The email of the admin' }),
  PORT: port(),
}

const env = envalid.cleanEnv(
  process.env,
  {
    STAGE: varDefs.STAGE,
    ...swit(
      process.env.STAGE,
      ['dev', 'local-prod', pick(varDefs, 'TRUE', 'PORT')],
      ['staging', 'prod', pick(varDefs, 'EMAIL', 'PORT')]
    ),
  },
  { strict: true }
)

module.exports = env

Usage

npm install --save-dev @sharyn/env
# or
yarn add --dev @sharyn/env

@sharyn/env

With @sharyn/env, you can import your environment variables directly:

import { NODE_ENV, PORT, DATABASE_URL } from '@sharyn/env'

This package simply runs dotenv/config and exports process.env for a convenient access.

Just use @sharyn/env in every file that needs access to the environment, and forget about dotenv and process.env completely.

@sharyn/env.check

@sharyn/env.check can also help you validate environment variables.


This package is part of Sharyn, a collection of utilities and helpers.

Current Tags

  • 3.5.4                                ...           latest (7 days ago)

52 Versions

  • 3.5.4                                ...           7 days ago
  • 3.5.3                                ...           8 days ago
  • 3.5.2                                ...           8 days ago
  • 3.5.1                                ...           8 days ago
  • 3.5.0                                ...           8 days ago
  • 3.4.1                                ...           8 days ago
  • 3.4.0                                ...           9 days ago
  • 3.3.0                                ...           11 days ago
  • 3.2.0                                ...           21 days ago
  • 3.1.2                                ...           21 days ago
  • 3.1.1                                ...           21 days ago
  • 3.1.0                                ...           21 days ago
  • 3.0.1                                ...           21 days ago
  • 3.0.0                                ...           22 days ago
  • 2.0.9                                ...           5 months ago
  • 2.0.8                                ...           a year ago
  • 2.0.7                                ...           a year ago
  • 2.0.6                                ...           a year ago
  • 2.0.5                                ...           a year ago
  • 2.0.4                                ...           a year ago
  • 2.0.3                                ...           a year ago
  • 2.0.2                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.8.5                                ...           a year ago
  • 1.8.4                                ...           a year ago
  • 1.8.3                                ...           a year ago
  • 1.8.2                                ...           a year ago
  • 1.8.1                                ...           a year ago
  • 1.8.0                                ...           a year ago
  • 1.7.0                                ...           a year ago
  • 1.6.2                                ...           a year ago
  • 1.6.1                                ...           a year ago
  • 1.6.0                                ...           a year ago
  • 1.5.0                                ...           a year ago
  • 1.4.2                                ...           a year ago
  • 1.4.1                                ...           a year ago
  • 1.4.0                                ...           a year ago
  • 1.3.6                                ...           a year ago
  • 1.3.5                                ...           a year ago
  • 1.3.4                                ...           a year ago
  • 1.3.3                                ...           a year ago
  • 1.3.2                                ...           a year ago
  • 1.3.1                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.1                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 69
This Month 191
Last Day 0
Last Week 122
Last Month 104
Dependencies (2)
Dev Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |