Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
'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', {
.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 => {
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();
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();
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();
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);
});
});
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();
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();