Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/roitinnovation/roit-environment
Roit Enviroments
https://github.com/roitinnovation/roit-environment
Last synced: about 2 months ago
JSON representation
Roit Enviroments
- Host: GitHub
- URL: https://github.com/roitinnovation/roit-environment
- Owner: roitinnovation
- License: mit
- Created: 2022-01-02T17:15:41.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-29T17:20:55.000Z (almost 3 years ago)
- Last Synced: 2024-11-11T20:48:02.826Z (about 2 months ago)
- Language: TypeScript
- Size: 10.5 MB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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: trueEnvironment.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 loadingimport { 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
```