Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
gateway-proxy / usr / share / gateway-proxy / app / dist / config.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getContentConfig = exports.getStampsConfig = exports.getServerConfig = exports.getAppConfig = exports.logLevel = exports.ERROR_NO_STAMP = exports.READINESS_TIMEOUT_MS = exports.MINIMAL_EXTENDS_TTL_VALUE = exports.DEFAULT_LOG_LEVEL = exports.DEFAULT_POSTAGE_REFRESH_PERIOD = exports.DEFAULT_POSTAGE_USAGE_MAX = exports.DEFAULT_POSTAGE_USAGE_THRESHOLD = exports.DEFAULT_PORT = exports.DEFAULT_HOSTNAME = exports.DEFAULT_BEE_DEBUG_API_URL = exports.DEFAULT_BEE_API_URL = exports.SUPPORTED_LEVELS = void 0;
exports.SUPPORTED_LEVELS = ['critical', 'error', 'warn', 'info', 'verbose', 'debug'];
exports.DEFAULT_BEE_API_URL = 'http://localhost:1633';
exports.DEFAULT_BEE_DEBUG_API_URL = 'http://localhost:1635';
exports.DEFAULT_HOSTNAME = 'localhost';
exports.DEFAULT_PORT = 3000;
exports.DEFAULT_POSTAGE_USAGE_THRESHOLD = 0.7;
exports.DEFAULT_POSTAGE_USAGE_MAX = 0.9;
exports.DEFAULT_POSTAGE_REFRESH_PERIOD = 60000;
exports.DEFAULT_LOG_LEVEL = 'info';
exports.MINIMAL_EXTENDS_TTL_VALUE = 60;
exports.READINESS_TIMEOUT_MS = 3000;
exports.ERROR_NO_STAMP = 'No postage stamp';
exports.logLevel = process.env.LOG_LEVEL && exports.SUPPORTED_LEVELS.includes(process.env.LOG_LEVEL)
    ? process.env.LOG_LEVEL
    : exports.DEFAULT_LOG_LEVEL;
function getAppConfig({ BEE_API_URL, BEE_DEBUG_API_URL, AUTH_SECRET, CID_SUBDOMAINS, ENS_SUBDOMAINS, HOSTNAME, REMOVE_PIN_HEADER, EXPOSE_HASHED_IDENTITY, } = {}) {
    return {
        hostname: HOSTNAME || exports.DEFAULT_HOSTNAME,
        beeApiUrl: BEE_API_URL || exports.DEFAULT_BEE_API_URL,
        beeDebugApiUrl: BEE_DEBUG_API_URL || exports.DEFAULT_BEE_DEBUG_API_URL,
        authorization: AUTH_SECRET,
        cidSubdomains: CID_SUBDOMAINS === 'true',
        ensSubdomains: ENS_SUBDOMAINS === 'true',
        removePinHeader: REMOVE_PIN_HEADER ? REMOVE_PIN_HEADER === 'true' : true,
        exposeHashedIdentity: EXPOSE_HASHED_IDENTITY === 'true',
    };
}
exports.getAppConfig = getAppConfig;
function getServerConfig({ PORT, HOSTNAME } = {}) {
    return { hostname: HOSTNAME || exports.DEFAULT_HOSTNAME, port: Number(PORT || exports.DEFAULT_PORT) };
}
exports.getServerConfig = getServerConfig;
function getStampsConfig({ BEE_DEBUG_API_URL, POSTAGE_STAMP, POSTAGE_DEPTH, POSTAGE_AMOUNT, POSTAGE_USAGE_THRESHOLD, POSTAGE_USAGE_MAX, POSTAGE_TTL_MIN, POSTAGE_REFRESH_PERIOD, POSTAGE_EXTENDSTTL, } = {}) {
    const refreshPeriod = Number(POSTAGE_REFRESH_PERIOD || exports.DEFAULT_POSTAGE_REFRESH_PERIOD);
    const beeDebugApiUrl = BEE_DEBUG_API_URL || exports.DEFAULT_BEE_DEBUG_API_URL;
    // Start in hardcoded mode
    if (POSTAGE_STAMP)
        return { mode: 'hardcoded', stamp: POSTAGE_STAMP };
    // Start autobuy
    else if (!POSTAGE_EXTENDSTTL && POSTAGE_DEPTH && POSTAGE_AMOUNT && BEE_DEBUG_API_URL) {
        return {
            mode: 'autobuy',
            depth: Number(POSTAGE_DEPTH),
            amount: POSTAGE_AMOUNT,
            usageThreshold: Number(POSTAGE_USAGE_THRESHOLD || exports.DEFAULT_POSTAGE_USAGE_THRESHOLD),
            usageMax: Number(POSTAGE_USAGE_MAX || exports.DEFAULT_POSTAGE_USAGE_MAX),
            ttlMin: Number(POSTAGE_TTL_MIN || (refreshPeriod / 1000) * 5),
            refreshPeriod,
            beeDebugApiUrl,
        };
    }
    else if (POSTAGE_EXTENDSTTL === 'true' &&
        POSTAGE_AMOUNT &&
        POSTAGE_DEPTH &&
        Number(POSTAGE_TTL_MIN) >= exports.MINIMAL_EXTENDS_TTL_VALUE) {
        return {
            mode: 'extendsTTL',
            depth: Number(POSTAGE_DEPTH),
            ttlMin: Number(POSTAGE_TTL_MIN),
            amount: POSTAGE_AMOUNT,
            refreshPeriod,
            beeDebugApiUrl,
        };
    }
    // Missing one of the variables needed for the autobuy or extends TTL
    else if (POSTAGE_DEPTH || POSTAGE_AMOUNT || POSTAGE_TTL_MIN || BEE_DEBUG_API_URL) {
        throw new Error(`config: please provide POSTAGE_DEPTH=${POSTAGE_DEPTH}, POSTAGE_AMOUNT=${POSTAGE_AMOUNT}, POSTAGE_TTL_MIN=${POSTAGE_TTL_MIN} ${POSTAGE_EXTENDSTTL === 'true' ? 'at least 60 seconds ' : ''}or BEE_DEBUG_API_URL=${BEE_DEBUG_API_URL} for the feature to work`);
    }
    // Stamps rewrite is disabled
    return undefined;
}
exports.getStampsConfig = getStampsConfig;
function getContentConfig({ BEE_API_URL, REUPLOAD_PERIOD } = {}) {
    if (!REUPLOAD_PERIOD) {
        return false;
    }
    return {
        beeApiUrl: BEE_API_URL || exports.DEFAULT_BEE_API_URL,
        refreshPeriod: Number(REUPLOAD_PERIOD),
    };
}
exports.getContentConfig = getContentConfig;