# roit-environment

> Facilitate environment management in node applications

Latest version **1.1.4** (published 2022-03-29) · 0 weekly downloads

## Install

```sh
npm install roit-environment
pnpm add roit-environment
yarn add roit-environment
bun add roit-environment
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2022-03-29 |
| First published | 2019-08-01 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 46.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jeremias Silva |
| Maintainers | jeremias.silva |
| Keywords | env, environment, google function environment, dotenv, env., envenvironment, variables, config, settings |

## Links

- npm: https://www.npmjs.com/package/roit-environment
- Repository: https://github.com/roitinnovation/roit-environment
- Homepage: https://github.com/roitinnovation/roit-environment#readme
- Issues: https://github.com/roitinnovation/roit-environment/issues
- npm.io page: https://npm.io/package/roit-environment

## Dependencies (5)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [yamljs](https://npm.io/package/yamljs.md) ^0.3.0
- [dot-object](https://npm.io/package/dot-object.md) ^1.9.0
- [@types/yamljs](https://npm.io/package/@types/yamljs.md) 0.2.31
- [@types/dot-object](https://npm.io/package/@types/dot-object.md) 2.1.1

## 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.1.4 (latest) — 2022-03-29
- 1.1.3 — 2022-01-02
- 1.1.2 — 2021-10-29
- 1.1.1 — 2020-05-27
- 1.1.0 — 2020-05-26
- 1.0.22 — 2020-05-11
- 1.0.21 — 2020-02-17
- 1.0.20 — 2019-12-26
- 1.0.19 — 2019-12-12
- 1.0.18 — 2019-12-12
- 1.0.17 — 2019-12-09
- 1.0.16 — 2019-12-09
- 1.0.15 — 2019-12-09
- 1.0.14 — 2019-12-09
- 1.0.13 — 2019-12-09
- … 25 more at https://npm.io/package/roit-environment/versions

## README

# ROIT environment lib
Facilitate environment management in node applications

## Usage
-----------

### Declaring variables in a file:

```
root-path/env.yaml
```

```yaml

serviceName: Service A
serviceInfo:
  version: '1.0'

# Development-specific settings. 
dev:
  port: 3000
  dropDatabase: true
  credential: config/dev/foobar.json
  credentialLevel{3}: foobar.json
  pg:
    host: 172.1.2.208
    user: myuserpg
    pass:
      inner: mysafepass
# Homologation-specific settings. 
hom:
  port: 9001
  dropDatabase: false
  credential: config/hom/foobar.json
# Production-specific settings. 
prod:
  port: 80
  dropDatabase: false
  credential: config/prod/foobar.json
```
### Example for importing and invoking method:

```javascript

import { Environment, Env } from 'roit-environment';

Environment.getProperty("port") // output: 3000

// Verify env is accepted
Environment.acceptedEnv(Env.HOM) // output: false
Environment.acceptedEnv(Env.DEV) // output: true

Environment.currentEnv() // return enum Env

// Relative path example
root
  -config
   --dev
    ---foobar.json
// Param 1: subs level number (3)
// Param 2: key property
Environment.getRelativePath(3, 'credential') // output: ../../../config/dev/foobar.json

// Childrens property 
Environment.getProperty("pg.host") // output: 172.1.2.208
Environment.getProperty("pg.pass.inner") // output: mysafepass

```
### Env Options:

```javascript

// Attributes:
// manuallyEnv: set manual env
// fileYamlName: especify file name for internal loading

import { Environment } from 'roit-environment';

Environment.envOptions({ manuallyEnv: Env.PROD, fileYamlName: 'foo.yaml' })

Environment.getProperty("port") // output: 80 (port from env prod)

```

## Activate environment

Node param

```
ENV=dev node index.js
```

Google function example (--set-env-vars)

```shell
# hom example
gcloud functions deploy FUNCTION_NAME --runtime RUNTIME_PARAM --trigger-http --project PROJECT --set-env-vars ENV=hom
# prod example
gcloud functions deploy FUNCTION_NAME --runtime RUNTIME_PARAM --trigger-http --project PROJECT --set-env-vars ENV=prod
```

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