Socket
Socket
Sign inDemoInstall

roit-environment

Package Overview
Dependencies
25
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    roit-environment

Facilitate environment management in node applications


Version published
Weekly downloads
1.3K
decreased by-48.2%
Maintainers
1
Install size
1.24 MB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 29 Mar 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc