How to use env-var - 10 common examples

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 Ethercast / serverless-blockstream / src / util / env.ts View on Github external
import * as env from 'env-var';
import { LogLevel } from 'bunyan';

export const SRC_NODE_URL: string = env.get('SRC_NODE_URL').required().asUrlString();
export const NETWORK_ID: number = env.get('NETWORK_ID').required().asIntPositive();

export const LOG_LEVEL: LogLevel = env.get('LOG_LEVEL').required().asString() as LogLevel;

export const BLOCK_DATA_TTL_MS: number = env.get('BLOCK_DATA_TTL_MS').required().asIntPositive();

// OWNED RESOURCES
export const BLOCKS_TABLE: string = env.get('BLOCKS_TABLE').required().asString();
export const BLOCKSTREAM_STATE_TABLE: string = env.get('BLOCKSTREAM_STATE_TABLE').required().asString();
export const ABI_TABLE: string = env.get('ABI_TABLE').required().asString();

export const NEW_BLOCK_QUEUE_NAME: string = env.get('NEW_BLOCK_QUEUE_NAME').required().asString();
export const LOG_FIREHOSE_QUEUE_NAME: string = env.get('LOG_FIREHOSE_QUEUE_NAME').required().asString();
export const TRANSACTION_FIREHOSE_QUEUE_NAME: string = env.get('TRANSACTION_FIREHOSE_QUEUE_NAME').required().asString();

export const BLOCK_READY_TOPIC_NAME: string = env.get('BLOCK_READY_TOPIC_NAME').required().asString();
export const BLOCK_PROCESSED_TOPIC_NAME: string = env.get('BLOCK_PROCESSED_TOPIC_NAME').required().asString();

export const NUM_BLOCKS_DELAY: number = env.get('NUM_BLOCKS_DELAY').required().asIntPositive();

export const REWIND_BLOCK_LOOKBACK: number = env.get('REWIND_BLOCK_LOOKBACK').required().asIntPositive();

export const ETHERSCAN_API_URL: string = env.get('ETHERSCAN_API_URL').required().asUrlString();
export const ETHERSCAN_API_KEY: string = env.get('ETHERSCAN_API_KEY').required().asString();
github RedHatWorkshops / dayinthelife-streaming / projects / module-1-ui-web / server / index.js View on Github external
'use strict'

require('make-promises-safe')

const http = require('http')
const exphbs = require('express-handlebars')
const express = require('express')
const env = require('env-var')
const probe = require('kube-probe')
const { join } = require('path')
const wssOutgoing = require('./ws-outgoing')
const log = require('./log')

const PORT = env.get('PORT', 8080).asPortNumber()
const WS_CONNECTION_STRING = env.get('WS_CONNECTION_STRING').asUrlString()

// Create an express app, attach it to a http server,
// and bind a websocket server to the same socket
const app = express()
const server = http.createServer(app)

// Kubernetes liveness readiness probes
probe(app)

app.engine('handlebars', exphbs())
app.set('views', join(__dirname, '/views'))
app.set('view engine', 'handlebars')

app.get('/', (req, res) => {
  res.render('home.handlebars', {
github aws-samples / reinvent2018-dev303-code / src / frontend / routes / product.js View on Github external
.then(value => {
        var products = value.data;

        // fetch recommendations next, ignore errors here
        axios_client
          .get(
            "http://" +
              env.get("RECOMMENDER_ENDPOINT").asString() +
              "/api/v1/recommender/" +
              product_id
          )
          .then(v => {
            var rec = v.data['recommendations'];
            render(res, req, products, rec);
          })
          .catch(error => {
            render(res, req, products, undefined);
          });
      })
      .catch(e => {
github Ethercast / serverless-blockstream / src / util / env.ts View on Github external
import * as env from 'env-var';
import { LogLevel } from 'bunyan';

export const SRC_NODE_URL: string = env.get('SRC_NODE_URL').required().asUrlString();
export const NETWORK_ID: number = env.get('NETWORK_ID').required().asIntPositive();

export const LOG_LEVEL: LogLevel = env.get('LOG_LEVEL').required().asString() as LogLevel;

export const BLOCK_DATA_TTL_MS: number = env.get('BLOCK_DATA_TTL_MS').required().asIntPositive();

// OWNED RESOURCES
export const BLOCKS_TABLE: string = env.get('BLOCKS_TABLE').required().asString();
export const BLOCKSTREAM_STATE_TABLE: string = env.get('BLOCKSTREAM_STATE_TABLE').required().asString();
export const ABI_TABLE: string = env.get('ABI_TABLE').required().asString();

export const NEW_BLOCK_QUEUE_NAME: string = env.get('NEW_BLOCK_QUEUE_NAME').required().asString();
export const LOG_FIREHOSE_QUEUE_NAME: string = env.get('LOG_FIREHOSE_QUEUE_NAME').required().asString();
export const TRANSACTION_FIREHOSE_QUEUE_NAME: string = env.get('TRANSACTION_FIREHOSE_QUEUE_NAME').required().asString();

export const BLOCK_READY_TOPIC_NAME: string = env.get('BLOCK_READY_TOPIC_NAME').required().asString();
export const BLOCK_PROCESSED_TOPIC_NAME: string = env.get('BLOCK_PROCESSED_TOPIC_NAME').required().asString();

export const NUM_BLOCKS_DELAY: number = env.get('NUM_BLOCKS_DELAY').required().asIntPositive();

export const REWIND_BLOCK_LOOKBACK: number = env.get('REWIND_BLOCK_LOOKBACK').required().asIntPositive();

export const ETHERSCAN_API_URL: string = env.get('ETHERSCAN_API_URL').required().asUrlString();
export const ETHERSCAN_API_KEY: string = env.get('ETHERSCAN_API_KEY').required().asString();
github Ethercast / serverless-blockstream / src / util / env.ts View on Github external
import * as env from 'env-var';
import { LogLevel } from 'bunyan';

export const SRC_NODE_URL: string = env.get('SRC_NODE_URL').required().asUrlString();
export const NETWORK_ID: number = env.get('NETWORK_ID').required().asIntPositive();

export const LOG_LEVEL: LogLevel = env.get('LOG_LEVEL').required().asString() as LogLevel;

export const BLOCK_DATA_TTL_MS: number = env.get('BLOCK_DATA_TTL_MS').required().asIntPositive();

// OWNED RESOURCES
export const BLOCKS_TABLE: string = env.get('BLOCKS_TABLE').required().asString();
export const BLOCKSTREAM_STATE_TABLE: string = env.get('BLOCKSTREAM_STATE_TABLE').required().asString();
export const ABI_TABLE: string = env.get('ABI_TABLE').required().asString();

export const NEW_BLOCK_QUEUE_NAME: string = env.get('NEW_BLOCK_QUEUE_NAME').required().asString();
export const LOG_FIREHOSE_QUEUE_NAME: string = env.get('LOG_FIREHOSE_QUEUE_NAME').required().asString();
export const TRANSACTION_FIREHOSE_QUEUE_NAME: string = env.get('TRANSACTION_FIREHOSE_QUEUE_NAME').required().asString();

export const BLOCK_READY_TOPIC_NAME: string = env.get('BLOCK_READY_TOPIC_NAME').required().asString();
export const BLOCK_PROCESSED_TOPIC_NAME: string = env.get('BLOCK_PROCESSED_TOPIC_NAME').required().asString();
github Ethercast / serverless-blockstream / src / util / env.ts View on Github external
import * as env from 'env-var';
import { LogLevel } from 'bunyan';

export const SRC_NODE_URL: string = env.get('SRC_NODE_URL').required().asUrlString();
export const NETWORK_ID: number = env.get('NETWORK_ID').required().asIntPositive();

export const LOG_LEVEL: LogLevel = env.get('LOG_LEVEL').required().asString() as LogLevel;

export const BLOCK_DATA_TTL_MS: number = env.get('BLOCK_DATA_TTL_MS').required().asIntPositive();

// OWNED RESOURCES
export const BLOCKS_TABLE: string = env.get('BLOCKS_TABLE').required().asString();
export const BLOCKSTREAM_STATE_TABLE: string = env.get('BLOCKSTREAM_STATE_TABLE').required().asString();
export const ABI_TABLE: string = env.get('ABI_TABLE').required().asString();

export const NEW_BLOCK_QUEUE_NAME: string = env.get('NEW_BLOCK_QUEUE_NAME').required().asString();
export const LOG_FIREHOSE_QUEUE_NAME: string = env.get('LOG_FIREHOSE_QUEUE_NAME').required().asString();
export const TRANSACTION_FIREHOSE_QUEUE_NAME: string = env.get('TRANSACTION_FIREHOSE_QUEUE_NAME').required().asString();

export const BLOCK_READY_TOPIC_NAME: string = env.get('BLOCK_READY_TOPIC_NAME').required().asString();
export const BLOCK_PROCESSED_TOPIC_NAME: string = env.get('BLOCK_PROCESSED_TOPIC_NAME').required().asString();

export const NUM_BLOCKS_DELAY: number = env.get('NUM_BLOCKS_DELAY').required().asIntPositive();

export const REWIND_BLOCK_LOOKBACK: number = env.get('REWIND_BLOCK_LOOKBACK').required().asIntPositive();

export const ETHERSCAN_API_URL: string = env.get('ETHERSCAN_API_URL').required().asUrlString();
export const ETHERSCAN_API_KEY: string = env.get('ETHERSCAN_API_KEY').required().asString();
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/
github aws-samples / reinvent2018-dev303-code / src / frontend / routes / product.js View on Github external
router.get("/", function(req, res, next) {
  axios_client
    .get(
      "http://" + env.get("CATALOG_ENDPOINT").asString() + "/api/v1/products"
    )
    .then(function(value) {
      res.render("products", {
        title: "AnyCompany Shop - All Products",
        product: value.data,
        user: req.user
      });
    })
    .catch(error => {
      //log but ignore error
      //console.log(error.message)
      next(error);
    });
});
github Ethercast / serverless-blockstream / src / util / env.ts View on Github external
export const BLOCKS_TABLE: string = env.get('BLOCKS_TABLE').required().asString();
export const BLOCKSTREAM_STATE_TABLE: string = env.get('BLOCKSTREAM_STATE_TABLE').required().asString();
export const ABI_TABLE: string = env.get('ABI_TABLE').required().asString();

export const NEW_BLOCK_QUEUE_NAME: string = env.get('NEW_BLOCK_QUEUE_NAME').required().asString();
export const LOG_FIREHOSE_QUEUE_NAME: string = env.get('LOG_FIREHOSE_QUEUE_NAME').required().asString();
export const TRANSACTION_FIREHOSE_QUEUE_NAME: string = env.get('TRANSACTION_FIREHOSE_QUEUE_NAME').required().asString();

export const BLOCK_READY_TOPIC_NAME: string = env.get('BLOCK_READY_TOPIC_NAME').required().asString();
export const BLOCK_PROCESSED_TOPIC_NAME: string = env.get('BLOCK_PROCESSED_TOPIC_NAME').required().asString();

export const NUM_BLOCKS_DELAY: number = env.get('NUM_BLOCKS_DELAY').required().asIntPositive();

export const REWIND_BLOCK_LOOKBACK: number = env.get('REWIND_BLOCK_LOOKBACK').required().asIntPositive();

export const ETHERSCAN_API_URL: string = env.get('ETHERSCAN_API_URL').required().asUrlString();
export const ETHERSCAN_API_KEY: string = env.get('ETHERSCAN_API_KEY').required().asString();

env-var

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

MIT
Latest version published 6 months ago

Package Health Score

78 / 100
Full package analysis

Popular env-var functions