1.1.4 • Published 2 years ago
roit-environment v1.1.4
ROIT environment lib
Facilitate environment management in node applications
Usage
Declaring variables in a file:
root-path/env.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:
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:
// 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)
# 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
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.1.1
4 years ago
1.1.0
4 years ago
1.0.22
4 years ago
1.0.21
4 years ago
1.0.20
4 years ago
1.0.19
4 years ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.12
4 years ago
1.0.11
4 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
0.0.13
5 years ago
0.0.12
5 years ago
0.0.11
5 years ago
0.0.10
5 years ago
0.0.9
5 years ago
0.0.8
5 years ago
0.0.7
5 years ago
0.0.6
5 years ago
0.0.5
5 years ago
0.0.4
5 years ago
0.0.3
5 years ago
0.0.2
5 years ago
0.0.1
5 years ago