# env_helper_ts

> A npm package that helps load .env files and operates on secrets in the azure key vault

Latest version **1.1.16** (published 2019-06-28) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install env_helper_ts
pnpm add env_helper_ts
yarn add env_helper_ts
bun add env_helper_ts
```

## 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.1.16 |
| Published | 2019-06-28 |
| First published | 2019-05-30 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 43.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ryan Bell - Lake Sain-Thomason |
| Maintainers | lil_doggo, ryanwbell, yzhaopost |

## Links

- npm: https://www.npmjs.com/package/env_helper_ts
- Repository: https://github.com/Commission-on-POST/enb_helper_ts_ts
- Homepage: https://github.com/Commission-on-POST/enb_helper_ts_ts#readme
- Issues: https://github.com/Commission-on-POST/enb_helper_ts_ts/issues
- npm.io page: https://npm.io/package/env_helper_ts

## Dependencies (4)

- [ts](https://npm.io/package/ts.md) ^0.2.2
- [dotenv-flow](https://npm.io/package/dotenv-flow.md) ^0.4.0
- [querystring](https://npm.io/package/querystring.md) ^0.2.0
- [post_ltr_logger](https://npm.io/package/post_ltr_logger.md) ^2.0.15

## Recent versions

- 1.1.16 (latest) — 2019-06-28
- 1.1.15 — 2019-06-28
- 1.1.14 — 2019-06-28
- 1.1.13 — 2019-06-25
- 1.1.12 — 2019-06-25
- 1.1.10 — 2019-06-25
- 1.1.9 — 2019-06-25
- 1.1.8 — 2019-06-25
- 1.1.7 — 2019-06-24
- 1.1.6 — 2019-06-24
- 1.1.5 — 2019-06-24
- 1.1.4 — 2019-06-21
- 1.1.3 — 2019-06-21
- 1.1.2 — 2019-06-20
- 1.1.1 — 2019-06-20
- … 2 more at https://npm.io/package/env_helper_ts/versions

## README

# env_helper_ts

<img src="https://raw.githubusercontent.com/RyanWBell/images/master/envLogo.png" align="right" alt="Env+ logo" width="110" height=110>

Env helper is a helper extension library layer provided for the [**`Code 3`**](https://github.com/Commission-on-POST) code base. It's design was to provide a unified and easy means of retrieving .env configuration variables from files.

## Files

- [**EnvChecker**](./src/EnvChecker.ts).ts - Has most of the real functionality of this extension library and exposes several methods that may help programmers check.env related configurations.
- [**Converter**](./src/Converter.ts).ts - Is an abstract base class that all the other converters are based off of.
- **To{Converter}**.ts - All of the converters (such as: [ToNumber.ts](./src/ToNumber.ts)) convert a given string into their the type indicated by their class name. (So ToNumber would convert a given string loaded from a .env file to a number.)

## Installation

Install the npm package:

```npm
$ npm install env_helper_ts
```

This is intended to be used as an [_NPM Package_](https://www.npmjs.com/package/env_helper_ts), but if you want to add your own type conversion you can compile it and test it using the commands below:

##### Build :hammer:

```npm
$ npm install
$ npm start
```

##### Test :mag_right:

```npm
$ npm test
```

## Usage :bowtie:

```typescript
const secretObjects = [
  { name: "DB_TEST", value: "someConnectionString" },
  { name: "myTestKey", value: "YAYAYA" },
  { name: "aNumber", value: 1 }
];
const secretNames = ["DB_TEST", "myTestKey", "aNumber"];

const myVault = new Vault(clientID, clientSecret, loginAPI, vaultAPI);
myVault
  .getAccessToken() // Get the access token. First operation required for operating on the class
  .then(() => {
    return Promise.all(myVault.setSecretsInVault(setSecrets)); // Set the secrets in the key vault
  })
  .then(() => {
    return Promise.all(myVault.getSecretsFromVault(getSecrets)); // Get the secrets in the key vault
  })
  .then(secrets => {
    console.log(secrets); // Array of {name, value, contentType}
  })
  .catch(error => {
    console.log(error); // 4xx - 5xx level network errors
  })
  .finally(() => {
    getSecrets.forEach(secret => {
      console.log(process.env[secret]); // All get and set operations cache secret in the process.env object
    });
    console.log(typeof getRequiredEnv("aNumber", ToNumber)); // Continue to use getRequiredEnv with type conversion
  });
```

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