import dotenv from 'dotenv' import Utils from './Util/Utils.js' // important for dev env to load .env file dotenv.config() /** * Class containing global constants and configurations for the application. */ export default class Globals { /** * A constant string representing an error message for input validation failure. */ public static ErrorResponseValidationFail = 'Input validation failed: ' //400 /** * A constant string representing an error response for an invalid server response. */ public static ErrorResponseInvalidServerResponse = 'No valid response, this is a system error.' //400 /** * The error message for an unhandled error when processing a request. */ public static ErrorResponseUnhandledError = 'Unhandled error when processing request.' //400 /** * A static string representing an error response when there are no records to be processed. */ public static ErrorResponseNoRecords = 'No events to be processed.' //400 /** * Represents an error code for a missing parameter. * @type {string} */ public static ErrorCode_MissingParam = 'MISSING_PARAM' /** * Represents an error code for invalid input. * @type {string} */ public static ErrorCode_InvalidInput = 'INVALID_INPUT' /** * Represents an error code for an API error. * @type {string} */ public static ErrorCode_APIError = 'API_ERROR' /** * Represents the error code for when there are no records found. * @type {string} */ public static ErrorCode_NoRecords = 'EMPTY_EVENT' /** * Retrieves the default port number for HTTP listeners. * The port number is obtained from the environment variable "PORT" and parsed as an integer. * If the environment variable is not set or cannot be parsed as an integer, the default port number 9000 is used. * @returns {number} - The default port number for HTTP listeners. */ public static Listener_HTTP_DefaultPort = Utils.parseIntNullIfNaN(process.env.PORT) || 9000 /** * The default host for the HTTP listener. */ public static Listener_HTTP_DefaultHost = 'localhost' /** * The HTTP proxy route listener for all routes. * @type {string} */ public static Listener_HTTP_ProxyRoute = '*' /** * Retrieves the default timeout value for HTTP listeners. * @returns {number} The default timeout value in milliseconds. */ public static Listener_HTTP_DefaultTimeout = Utils.parseIntNullIfNaN(process.env.TIMEOUT) || 30000 /** * The default health check route for the HTTP listener. * @type {string} */ public static Listener_HTTP_DefaultHealthCheckRoute = process.env.HEALTH_ROUTE || '/health' /** * The response message for an exception that occurred during request execution in the Proxy. */ public static Resp_MSG_EXCEPTION = '[Proxy]: Exception during request execution!' /** * The response code for an exception that occurred during execution. */ public static Resp_CODE_EXCEPTION = 'EXEC_EXCEPTION' /** * The HTTP response status code for an exception scenario. */ public static Resp_STATUSCODE_EXCEPTION = 502 /** * The error message for an invalid response from the server. */ public static Resp_MSG_INVALIDRESP = '[Proxy]: Invalid response from server!' /** * Represents the response code for an invalid response. */ public static Resp_CODE_INVALIDRESP = 'EMPTY_RESPONSE' /** * The HTTP response status code for an invalid response. * @type {number} * @default 400 */ public static Resp_STATUSCODE_INVALIDRESP = 400 }