How to use the env-var.from function in env-var

To help you get started, we’ve selected a few env-var examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RedHatWorkshops / dayinthelife-streaming / projects / module-0-ui-mobile-new / lib / config.js View on Github external
module.exports = (env) => {
  assert(typeof env === 'object', 'config.js requires a process.env argument')

  const { get } = from(env)

  return {
    HTTP_PORT: get('HTTP_PORT', 8080).asPortNumber(),

    NODE_ENV: get('NODE_ENV').asString(),

    LOG_LEVEL: get('LOG_LEVEL', 'info').asEnum(Object.values(pino.levels.labels)),

    // Can be set to valid keycloak config for a "public" client
    KEYCLOAK_CONFIG: get('KEYCLOAK_CONFIG').asJsonObject(),

    // If keycloak is configured we also need a session secret.
    // This will default to a random hex string if not set
    SESSION_SECRET: get('SESSION_SECRET', randomSessionSecret).asString(),

    // Ordering HTTP API base url, e.g http://orders.svc.local:8080/

env-var

Verification, sanitization, and type coercion for environment variables in Node.js

MIT
Latest version published 6 months ago

Package Health Score

84 / 100
Full package analysis

Popular env-var functions