oneuptime/Probe/Config.ts

55 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-05-05 12:02:23 +00:00
import URL from 'Common/Types/API/URL';
2023-05-03 10:54:25 +00:00
import logger from 'CommonServer/Utils/Logger';
2023-05-05 12:02:23 +00:00
import ObjectID from 'Common/Types/ObjectID';
2023-05-03 10:54:25 +00:00
2023-05-05 12:02:23 +00:00
if (!process.env['PROBE_API_URL']) {
logger.error('PROBE_API_URL is not set');
2023-05-03 10:54:25 +00:00
process.exit();
}
2023-09-22 15:36:04 +00:00
export let PROBE_API_URL: URL = URL.fromString(process.env['PROBE_API_URL']);
// If probe api does not have the path. Add it.
if (
!PROBE_API_URL.toString().endsWith('probe-api') &&
!PROBE_API_URL.toString().endsWith('probe-api/')
) {
PROBE_API_URL = URL.fromString(
PROBE_API_URL.addRoute('/probe-api').toString()
);
}
2023-05-03 10:54:25 +00:00
export const PROBE_NAME: string | null = process.env['PROBE_NAME'] || null;
2023-05-05 12:02:23 +00:00
export const PROBE_DESCRIPTION: string | null =
process.env['PROBE_DESCRIPTION'] || null;
2023-05-03 10:54:25 +00:00
2023-05-05 12:02:23 +00:00
export const PROBE_ID: ObjectID | null = process.env['PROBE_ID']
? new ObjectID(process.env['PROBE_ID'])
: null;
2023-05-03 10:54:25 +00:00
2023-05-05 12:02:23 +00:00
if (!process.env['PROBE_KEY']) {
logger.error('PROBE_KEY is not set');
2023-05-03 10:54:25 +00:00
process.exit();
}
export const PROBE_KEY: string = process.env['PROBE_KEY'];
2023-08-06 20:54:12 +00:00
let probeMonitoringWorkers: string | number =
process.env['PROBE_MONITORING_WORKERS'] || 1;
if (typeof probeMonitoringWorkers === 'string') {
probeMonitoringWorkers = parseInt(probeMonitoringWorkers);
}
export const PROBE_MONITORING_WORKERS: number = probeMonitoringWorkers;
2023-08-07 14:22:45 +00:00
let monitorFetchLimit: string | number =
process.env['PROBE_MONITOR_FETCH_LIMIT'] || 1;
if (typeof monitorFetchLimit === 'string') {
monitorFetchLimit = parseInt(monitorFetchLimit);
}
export const PROBE_MONITOR_FETCH_LIMIT: number = monitorFetchLimit;