Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 12x 12x 60x 256x 36x 18x 12x 12x 12x 12x 12x 12x 78x 78x 12x 12x 12x 12x 79x 79x 12x 12x 12x 12x 35x 12x 78x | import { config } from './config'
export type WorkerEnv = {
AGENT_SCRIPT_DOWNLOAD_PATH: string | null
GET_RESULT_PATH: string | null
PROXY_SECRET: string | null
FPJS_CDN_URL: string | null
FPJS_INGRESS_BASE_HOST: string | null
}
export const Defaults: WorkerEnv = {
AGENT_SCRIPT_DOWNLOAD_PATH: 'agent',
GET_RESULT_PATH: 'getResult',
PROXY_SECRET: null,
FPJS_CDN_URL: config.fpcdn,
FPJS_INGRESS_BASE_HOST: config.ingressApi,
}
function getVarOrDefault(variable: keyof WorkerEnv, defaults: WorkerEnv): (env: WorkerEnv) => string | null {
return function (env: WorkerEnv): string | null {
return (env[variable] || defaults[variable]) as string | null
}
}
function isVarSet(variable: keyof WorkerEnv): (env: WorkerEnv) => boolean {
return function (env: WorkerEnv): boolean {
return env[variable] != null
}
}
export const getCdnUrl = getVarOrDefault('FPJS_CDN_URL', Defaults)
export const getIngressBaseHost = getVarOrDefault('FPJS_INGRESS_BASE_HOST', Defaults)
export const agentScriptDownloadPathVarName = 'AGENT_SCRIPT_DOWNLOAD_PATH'
const getAgentPathVar = getVarOrDefault(agentScriptDownloadPathVarName, Defaults)
export const isScriptDownloadPathSet = isVarSet(agentScriptDownloadPathVarName)
export function getScriptDownloadPath(env: WorkerEnv): string {
const agentPathVar = getAgentPathVar(env)
return `/${agentPathVar}`
}
export const getResultPathVarName = 'GET_RESULT_PATH'
const getGetResultPathVar = getVarOrDefault(getResultPathVarName, Defaults)
export const isGetResultPathSet = isVarSet(getResultPathVarName)
export function getGetResultPath(env: WorkerEnv): string {
const getResultPathVar = getGetResultPathVar(env)
return `/${getResultPathVar}(/.*)?`
}
export const proxySecretVarName = 'PROXY_SECRET'
const getProxySecretVar = getVarOrDefault(proxySecretVarName, Defaults)
export const isProxySecretSet = isVarSet(proxySecretVarName)
export function getProxySecret(env: WorkerEnv): string | null {
return getProxySecretVar(env)
}
export function getStatusPagePath(): string {
return `/status`
}
|