# nope-env

> Environment variable validation using dotenv and nope-validator

Latest version **1.0.0** (published 2021-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install nope-env
pnpm add nope-env
yarn add nope-env
bun add nope-env
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-02-05 |
| First published | 2021-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Tiaan du Plessis |
| Maintainers | tiaanduplessis |
| Keywords | dotenv, dotenv-expand, nope, validate-env, env |

## Links

- npm: https://www.npmjs.com/package/nope-env
- npm.io page: https://npm.io/package/nope-env

## Dependencies (4)

- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [standard](https://npm.io/package/standard.md) ^16.0.3
- [dotenv-expand](https://npm.io/package/dotenv-expand.md) ^5.1.0
- [nope-validator](https://npm.io/package/nope-validator.md) ^0.11.3

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2021-02-05

## README

# nope-env
[![package version](https://img.shields.io/npm/v/nope-env.svg?style=flat-square)](https://npmjs.org/package/nope-env)
[![package downloads](https://img.shields.io/npm/dm/nope-env.svg?style=flat-square)](https://npmjs.org/package/nope-env)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![package license](https://img.shields.io/npm/l/nope-env.svg?style=flat-square)](https://npmjs.org/package/nope-env)
[![make a pull request](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

> Environment variable validation using [dotenv](https://github.com/motdotla/dotenv) & [nope-validator](https://github.com/bvego/nope-validator)

## Table of Contents

- [About](#about)
- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#License)

## About

This package is a small wrapper around [dotenv](https://github.com/motdotla/dotenv) & [nope-validator](https://github.com/bvego/nope-validator) which allows you to validate your environment variables based on a schema. It also includes [dotenv-expand](https://github.com/motdotla/dotenv-expand) for variable expansion.

## Install

This project uses [node](https://nodejs.org) and [npm](https://www.npmjs.com). 

```sh
$ npm install nope-env
$ # OR
$ yarn add nope-env
```

## Usage

Given we want the following environment variables to exist:

```bash
PROJECT_ENV=dev
# NOTE: We are using the ${} syntax from dotenv-expand here
NEXT_PUBLIC_API_URL=https://${PROJECT_ENV}.api.example.com
NEXT_PUBLIC_SENTRY_DSN=https://sentrydsn.com
ADMIN_EMAIL=admin@example.com
```

The following schema can be provided to `config`

```js
const env = require('nope-env')

env.config({
    // dotenv configuration can go here...
    schema: {
        // env.string() === Nope.string()
        PROJECT_ENV: env.string().oneOf(['dev', 'staging', 'uat']),
        NEXT_PUBLIC_API_URL: env.string().required().url(),
        NEXT_PUBLIC_SENTRY_DSN: env.string().url(),
        ADMIN_EMAIL: env.string().email().required()
    }
})
```

This package exposes all of the `nope-validator` API. Please see [their docs](https://github.com/bvego/nope-validator#api) for validation options.

## Contribute

1. Fork it and create your feature branch: `git checkout -b my-new-feature`
2. Commit your changes: `git commit -am "Add some feature"`
3. Push to the branch: `git push origin my-new-feature`
4. Submit a pull request

## License

MIT

---
_Source: https://npm.io/package/nope-env · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
