Best JavaScript code snippet using stryker-parent
Config.ts
Source:Config.ts
...34 Config.log_information = false;35 }36 public static reload(): void {37 Config.getversion();38 Config.logpath = Config.getEnv("logpath", __dirname);39 Config.log_cache = Config.parseBoolean(Config.getEnv("log_cache", "true"));40 Config.log_error_stack = Config.parseBoolean(Config.getEnv("log_error_stack", "false"));41 Config.log_errors = Config.parseBoolean(Config.getEnv("log_errors", "true"));42 Config.log_queries = Config.parseBoolean(Config.getEnv("log_queries", "false"));43 Config.log_aggregates = Config.parseBoolean(Config.getEnv("log_aggregates", "false"));44 Config.log_inserts = Config.parseBoolean(Config.getEnv("log_inserts", "false"));45 Config.log_updates = Config.parseBoolean(Config.getEnv("log_updates", "false"));46 Config.log_deletes = Config.parseBoolean(Config.getEnv("log_deletes", "false"));47 Config.log_otel_times = Config.parseBoolean(Config.getEnv("log_otel_times", "false"));48 Config.log_openflow_amqp = Config.parseBoolean(Config.getEnv("log_openflow_amqp", "false"));49 Config.log_amqp = Config.parseBoolean(Config.getEnv("log_amqp", "true"));50 Config.log_index_mngt = Config.parseBoolean(Config.getEnv("log_index_mngt", "true"));51 Config.log_watches = Config.parseBoolean(Config.getEnv("log_watches", "false"));52 Config.log_watches_notify = Config.parseBoolean(Config.getEnv("log_watches_notify", "false"));53 Config.log_missing_jwt = Config.parseBoolean(Config.getEnv("log_missing_jwt", "true"));54 Config.log_login_provider = Config.parseBoolean(Config.getEnv("log_login_provider", "false"));55 Config.log_information = Config.parseBoolean(Config.getEnv("log_information", "true"));56 Config.amqp_allow_replyto_empty_queuename = Config.parseBoolean(Config.getEnv("amqp_allow_replyto_empty_queuename", "false"));57 Config.openflow_uniqueid = Config.getEnv("openflow_uniqueid", "");58 Config.enable_openflow_amqp = Config.parseBoolean(Config.getEnv("enable_openflow_amqp", "false"));59 Config.openflow_amqp_expiration = parseInt(Config.getEnv("openflow_amqp_expiration", (60 * 1000 * 25).toString())); // 25 min60 Config.amqp_prefetch = parseInt(Config.getEnv("amqp_prefetch", "50"));61 Config.enable_entity_restriction = Config.parseBoolean(Config.getEnv("enable_entity_restriction", "false"));62 Config.enable_web_tours = Config.parseBoolean(Config.getEnv("enable_web_tours", "true"));63 Config.auto_hourly_housekeeping = Config.parseBoolean(Config.getEnv("auto_hourly_housekeeping", "false"));64 Config.housekeeping_update_usage_hourly = Config.parseBoolean(Config.getEnv("housekeeping_update_usage_hourly", "false"));65 Config.housekeeping_update_usersize_hourly = Config.parseBoolean(Config.getEnv("housekeeping_update_usersize_hourly", "true"));66 Config.housekeeping_skip_collections = Config.getEnv("housekeeping_skip_collections", "");67 Config.workitem_queue_monitoring_enabled = Config.parseBoolean(Config.getEnv("workitem_queue_monitoring_enabled", "true"));68 Config.workitem_queue_monitoring_interval = parseInt(Config.getEnv("workitem_queue_monitoring_interval", (30 * 1000).toString())); // 30 sec69 Config.getting_started_url = Config.getEnv("getting_started_url", "");70 Config.NODE_ENV = Config.getEnv("NODE_ENV", "development");71 Config.HTTP_PROXY = Config.getEnv("HTTP_PROXY", "");72 Config.HTTPS_PROXY = Config.getEnv("HTTPS_PROXY", "");73 Config.NO_PROXY = Config.getEnv("NO_PROXY", "");74 Config.stripe_api_key = Config.getEnv("stripe_api_key", "");75 Config.stripe_api_secret = Config.getEnv("stripe_api_secret", "");76 Config.stripe_force_vat = Config.parseBoolean(Config.getEnv("stripe_force_vat", "false"));77 Config.stripe_force_checkout = Config.parseBoolean(Config.getEnv("stripe_force_checkout", "true"));78 Config.supports_watch = Config.parseBoolean(Config.getEnv("supports_watch", "false"));79 Config.ensure_indexes = Config.parseBoolean(Config.getEnv("ensure_indexes", "true"));80 Config.auto_create_users = Config.parseBoolean(Config.getEnv("auto_create_users", "false"));81 Config.auto_create_user_from_jwt = Config.parseBoolean(Config.getEnv("auto_create_user_from_jwt", "false"));82 Config.auto_create_domains = Config.parseArray(Config.getEnv("auto_create_domains", ""));83 Config.persist_user_impersonation = Config.parseBoolean(Config.getEnv("persist_user_impersonation", "true"));84 Config.ping_clients_interval = parseInt(Config.getEnv("ping_clients_interval", (10000).toString())); // 12 seconds85 Config.allow_personal_nodered = Config.parseBoolean(Config.getEnv("allow_personal_nodered", "false"));86 Config.use_ingress_beta1_syntax = Config.parseBoolean(Config.getEnv("use_ingress_beta1_syntax", "true"));87 Config.auto_create_personal_nodered_group = Config.parseBoolean(Config.getEnv("auto_create_personal_nodered_group", "false"));88 Config.auto_create_personal_noderedapi_group = Config.parseBoolean(Config.getEnv("auto_create_personal_noderedapi_group", "false"));89 Config.force_add_admins = Config.parseBoolean(Config.getEnv("force_add_admins", "true"));90 Config.tls_crt = Config.getEnv("tls_crt", "");91 Config.tls_key = Config.getEnv("tls_key", "");92 Config.tls_ca = Config.getEnv("tls_ca", "");93 Config.tls_passphrase = Config.getEnv("tls_passphrase", "");94 Config.cache_store_type = Config.getEnv("cache_store_type", "memory");95 Config.cache_store_max = parseInt(Config.getEnv("cache_store_max", "1000"));96 Config.cache_store_ttl_seconds = parseInt(Config.getEnv("cache_store_ttl_seconds", "3600"));97 Config.cache_store_redis_host = Config.getEnv("cache_store_redis_host", "");98 Config.cache_store_redis_port = parseInt(Config.getEnv("cache_store_redis_port", "6379"));99 Config.cache_store_redis_password = Config.getEnv("cache_store_redis_password", "");100 Config.oidc_access_token_ttl = parseInt(Config.getEnv("oidc_access_token_ttl", "480"));101 Config.oidc_authorization_code_ttl = parseInt(Config.getEnv("oidc_authorization_code_ttl", "480"));102 Config.oidc_client_credentials_ttl = parseInt(Config.getEnv("oidc_client_credentials_ttl", "480"));103 Config.oidc_refresh_token_ttl = parseInt(Config.getEnv("oidc_refresh_token_ttl", "20160"));104 Config.oidc_session_ttl = parseInt(Config.getEnv("oidc_session_ttl", "20160"));105 Config.api_rate_limit = Config.parseBoolean(Config.getEnv("api_rate_limit", "true"));106 Config.api_rate_limit_points = parseInt(Config.getEnv("api_rate_limit_points", "60"));107 Config.api_rate_limit_duration = parseInt(Config.getEnv("api_rate_limit_duration", "1"));108 Config.socket_rate_limit = Config.parseBoolean(Config.getEnv("socket_rate_limit", "true"));109 Config.socket_rate_limit_points = parseInt(Config.getEnv("socket_rate_limit_points", "30"));110 Config.socket_rate_limit_points_disconnect = parseInt(Config.getEnv("socket_rate_limit_points_disconnect", "600"));111 Config.socket_rate_limit_duration = parseInt(Config.getEnv("socket_rate_limit_duration", "1"));112 Config.socket_error_rate_limit_points = parseInt(Config.getEnv("socket_error_rate_limit_points", "16"));113 Config.socket_error_rate_limit_duration = parseInt(Config.getEnv("socket_error_rate_limit_duration", "2"));114 Config.client_heartbeat_timeout = parseInt(Config.getEnv("client_heartbeat_timeout", "60"));115 Config.expected_max_roles = parseInt(Config.getEnv("expected_max_roles", "4000"));116 Config.decorate_roles_fetching_all_roles = Config.parseBoolean(Config.getEnv("decorate_roles_fetching_all_roles", "true"));117 Config.update_acl_based_on_groups = Config.parseBoolean(Config.getEnv("update_acl_based_on_groups", "false"));118 Config.multi_tenant = Config.parseBoolean(Config.getEnv("multi_tenant", "false"));119 Config.api_bypass_perm_check = Config.parseBoolean(Config.getEnv("api_bypass_perm_check", "false"));120 Config.websocket_package_size = parseInt(Config.getEnv("websocket_package_size", "4096"), 10);121 Config.websocket_max_package_count = parseInt(Config.getEnv("websocket_max_package_count", "1024"), 10);122 Config.protocol = Config.getEnv("protocol", "http"); // used by personal nodered and baseurl()123 Config.port = parseInt(Config.getEnv("port", "3000"));124 Config.domain = Config.getEnv("domain", "localhost"); // sent to website and used in baseurl()125 Config.cookie_secret = Config.getEnv("cookie_secret", "NLgUIsozJaxO38ze0WuHthfj2eb1eIEu");126 Config.amqp_reply_expiration = parseInt(Config.getEnv("amqp_reply_expiration", "10000")); // 10 seconds127 Config.amqp_force_queue_prefix = Config.parseBoolean(Config.getEnv("amqp_force_queue_prefix", "false"));128 Config.amqp_force_exchange_prefix = Config.parseBoolean(Config.getEnv("amqp_force_exchange_prefix", "false"));129 Config.amqp_force_sender_has_read = Config.parseBoolean(Config.getEnv("amqp_force_sender_has_read", "true"));130 Config.amqp_force_sender_has_invoke = Config.parseBoolean(Config.getEnv("amqp_force_sender_has_invoke", "false"));131 Config.amqp_force_consumer_has_update = Config.parseBoolean(Config.getEnv("amqp_force_consumer_has_update", "false"));132 Config.amqp_enabled_exchange = Config.parseBoolean(Config.getEnv("amqp_enabled_exchange", "false"));133 Config.amqp_url = Config.getEnv("amqp_url", "amqp://localhost"); // used to register queues and by personal nodered134 Config.amqp_username = Config.getEnv("amqp_username", "guest"); // used to talk wth rabbitmq api, used if not present in amqp_url135 Config.amqp_password = Config.getEnv("amqp_password", "guest"); // used to talk wth rabbitmq api, used if not present in amqp_url136 Config.amqp_check_for_consumer = Config.parseBoolean(Config.getEnv("amqp_check_for_consumer", "true"));137 Config.amqp_check_for_consumer_count = Config.parseBoolean(Config.getEnv("amqp_check_for_consumer_count", "false"));138 Config.amqp_default_expiration = parseInt(Config.getEnv("amqp_default_expiration", "10000")); // 10 seconds139 Config.amqp_requeue_time = parseInt(Config.getEnv("amqp_requeue_time", "1000")); // 1 seconds 140 Config.amqp_dlx = Config.getEnv("amqp_dlx", "openflow-dlx"); // Dead letter exchange, used to pickup dead or timeout messages141 Config.mongodb_url = Config.getEnv("mongodb_url", "mongodb://localhost:27017");142 Config.mongodb_db = Config.getEnv("mongodb_db", "openflow");143 Config.mongodb_minpoolsize = parseInt(Config.getEnv("mongodb_minpoolsize", "25"));144 Config.skip_history_collections = Config.getEnv("skip_history_collections", "");145 Config.history_delta_count = parseInt(Config.getEnv("history_delta_count", "1000"));146 Config.allow_skiphistory = Config.parseBoolean(Config.getEnv("allow_skiphistory", "true"));147 Config.saml_issuer = Config.getEnv("saml_issuer", "the-issuer"); // define uri of STS, also sent to personal nodereds148 Config.aes_secret = Config.getEnv("aes_secret", "");149 Config.signing_crt = Config.getEnv("signing_crt", "");150 Config.singing_key = Config.getEnv("singing_key", "");151 Config.shorttoken_expires_in = Config.getEnv("shorttoken_expires_in", "5m");152 Config.longtoken_expires_in = Config.getEnv("longtoken_expires_in", "365d");153 Config.downloadtoken_expires_in = Config.getEnv("downloadtoken_expires_in", "15m");154 Config.personalnoderedtoken_expires_in = Config.getEnv("personalnoderedtoken_expires_in", "365d");155 Config.nodered_images = JSON.parse(Config.getEnv("nodered_images", "[{\"name\":\"Latest Plain Nodered\", \"image\":\"openiap/nodered\"}]"));156 Config.saml_federation_metadata = Config.getEnv("saml_federation_metadata", "");157 Config.api_ws_url = Config.getEnv("api_ws_url", "");158 Config.nodered_ws_url = Config.getEnv("nodered_ws_url", "");159 Config.nodered_saml_entrypoint = Config.getEnv("nodered_saml_entrypoint", "");160 Config.nodered_docker_entrypoints = Config.getEnv("nodered_docker_entrypoints", "web");161 Config.nodered_docker_certresolver = Config.getEnv("nodered_docker_certresolver", "");162 Config.namespace = Config.getEnv("namespace", ""); // also sent to website 163 Config.nodered_domain_schema = Config.getEnv("nodered_domain_schema", ""); // also sent to website164 Config.nodered_initial_liveness_delay = parseInt(Config.getEnv("nodered_initial_liveness_delay", "60"));165 Config.nodered_allow_nodeselector = Config.parseBoolean(Config.getEnv("nodered_allow_nodeselector", "false"));166 Config.nodered_requests_memory = Config.getEnv("nodered_requests_memory", "");167 Config.nodered_requests_cpu = Config.getEnv("nodered_requests_cpu", ""); // 1000m = 1vCPU168 Config.nodered_limits_memory = Config.getEnv("nodered_limits_memory", "");169 Config.nodered_limits_cpu = Config.getEnv("nodered_limits_cpu", ""); // 1000m = 1vCPU170 Config.nodered_liveness_failurethreshold = parseInt(Config.getEnv("nodered_liveness_failurethreshold", "5"));171 Config.nodered_liveness_timeoutseconds = parseInt(Config.getEnv("nodered_liveness_timeoutseconds", "5"));172 Config.noderedcatalogues = Config.getEnv("noderedcatalogues", "");173 Config.prometheus_measure_nodeid = Config.parseBoolean(Config.getEnv("prometheus_measure_nodeid", "false"));174 Config.prometheus_measure_queued_messages = Config.parseBoolean(Config.getEnv("prometheus_measure_queued_messages", "false"));175 Config.prometheus_measure__mongodb_watch = Config.parseBoolean(Config.getEnv("prometheus_measure__mongodb_watch", "false"));176 Config.prometheus_measure_onlineuser = Config.parseBoolean(Config.getEnv("prometheus_measure_onlineuser", "false"));177 Config.enable_analytics = Config.parseBoolean(Config.getEnv("enable_analytics", "true"));178 Config.otel_debug_log = Config.parseBoolean(Config.getEnv("otel_debug_log", "false"));179 Config.otel_warn_log = Config.parseBoolean(Config.getEnv("otel_warn_log", "false"));180 Config.otel_err_log = Config.parseBoolean(Config.getEnv("otel_err_log", "false"));181 Config.otel_trace_url = Config.getEnv("otel_trace_url", "");182 Config.otel_metric_url = Config.getEnv("otel_metric_url", "");183 Config.otel_trace_interval = parseInt(Config.getEnv("otel_trace_interval", "5000"));184 Config.otel_metric_interval = parseInt(Config.getEnv("otel_metric_interval", "5000"));185 Config.otel_trace_pingclients = Config.parseBoolean(Config.getEnv("otel_trace_pingclients", "false"));186 Config.otel_trace_dashboardauth = Config.parseBoolean(Config.getEnv("otel_trace_dashboardauth", "false"));187 Config.otel_trace_include_query = Config.parseBoolean(Config.getEnv("otel_trace_include_query", "true"));188 189 Config.validate_user_form = Config.getEnv("validate_user_form", "");190 }191 public static db: DatabaseConnection = null;192 public static license_key: string = Config.getEnv("license_key", "");193 public static version: string = Config.getversion();194 public static logpath: string = Config.getEnv("logpath", __dirname);195 public static log_cache: boolean = Config.parseBoolean(Config.getEnv("log_cache", "false"));196 public static log_error_stack: boolean = Config.parseBoolean(Config.getEnv("log_error_stack", "false"));197 public static log_errors: boolean = Config.parseBoolean(Config.getEnv("log_errors", "true"));198 public static log_queries: boolean = Config.parseBoolean(Config.getEnv("log_queries", "false"));199 public static log_aggregates: boolean = Config.parseBoolean(Config.getEnv("log_aggregates", "false"));200 public static log_inserts: boolean = Config.parseBoolean(Config.getEnv("log_inserts", "false"));201 public static log_updates: boolean = Config.parseBoolean(Config.getEnv("log_updates", "false"));202 public static log_deletes: boolean = Config.parseBoolean(Config.getEnv("log_deletes", "false"));203 public static log_otel_times: boolean = Config.parseBoolean(Config.getEnv("log_otel_times", "false"));204 public static log_openflow_amqp: boolean = Config.parseBoolean(Config.getEnv("log_openflow_amqp", "false"));205 public static log_amqp: boolean = Config.parseBoolean(Config.getEnv("log_amqp", "true"));206 public static log_index_mngt: boolean = Config.parseBoolean(Config.getEnv("log_index_mngt", "true"));207 public static log_watches: boolean = Config.parseBoolean(Config.getEnv("log_watches", "false"));208 public static log_watches_notify: boolean = Config.parseBoolean(Config.getEnv("log_watches_notify", "false"));209 public static log_missing_jwt: boolean = Config.parseBoolean(Config.getEnv("log_missing_jwt", "true"));210 public static log_login_provider: boolean = Config.parseBoolean(Config.getEnv("log_login_provider", "false"));211 public static log_information: boolean = Config.parseBoolean(Config.getEnv("log_information", "true"));212 public static amqp_allow_replyto_empty_queuename: boolean = Config.parseBoolean(Config.getEnv("amqp_allow_replyto_empty_queuename", "false"));213 public static openflow_uniqueid: string = Config.getEnv("openflow_uniqueid", "");214 public static enable_openflow_amqp: boolean = Config.parseBoolean(Config.getEnv("enable_openflow_amqp", "false"));215 public static openflow_amqp_expiration: number = parseInt(Config.getEnv("openflow_amqp_expiration", (60 * 1000 * 25).toString())); // 25 min216 public static amqp_prefetch: number = parseInt(Config.getEnv("amqp_prefetch", "50"));217 public static enable_entity_restriction: boolean = Config.parseBoolean(Config.getEnv("enable_entity_restriction", "false"));218 public static enable_web_tours: boolean = Config.parseBoolean(Config.getEnv("enable_web_tours", "true"));219 public static auto_hourly_housekeeping: boolean = Config.parseBoolean(Config.getEnv("auto_hourly_housekeeping", "true"));220 public static housekeeping_update_usage_hourly: boolean = Config.parseBoolean(Config.getEnv("housekeeping_update_usage_hourly", "false"));221 public static housekeeping_update_usersize_hourly: boolean = Config.parseBoolean(Config.getEnv("housekeeping_update_usersize_hourly", "true"));222 public static housekeeping_skip_collections: string = Config.getEnv("housekeeping_skip_collections", "");223 public static workitem_queue_monitoring_enabled: boolean = Config.parseBoolean(Config.getEnv("workitem_queue_monitoring_enabled", "true"));224 public static workitem_queue_monitoring_interval: number = parseInt(Config.getEnv("workitem_queue_monitoring_interval", (30 * 1000).toString())); // 30 sec225 public static upload_max_filesize_mb: number = parseInt(Config.getEnv("upload_max_filesize_mb", "25"));226 public static getting_started_url: string = Config.getEnv("getting_started_url", "");227 public static NODE_ENV: string = Config.getEnv("NODE_ENV", "development");228 public static HTTP_PROXY: string = Config.getEnv("HTTP_PROXY", "");229 public static HTTPS_PROXY: string = Config.getEnv("HTTPS_PROXY", "");230 public static NO_PROXY: string = Config.getEnv("NO_PROXY", "");231 public static stripe_api_key: string = Config.getEnv("stripe_api_key", "");232 public static stripe_api_secret: string = Config.getEnv("stripe_api_secret", "");233 public static stripe_force_vat: boolean = Config.parseBoolean(Config.getEnv("stripe_force_vat", "false"));234 public static stripe_force_checkout: boolean = Config.parseBoolean(Config.getEnv("stripe_force_checkout", "false"));235 public static supports_watch: boolean = Config.parseBoolean(Config.getEnv("supports_watch", "false"));236 public static ensure_indexes: boolean = Config.parseBoolean(Config.getEnv("ensure_indexes", "true"));237 public static auto_create_users: boolean = Config.parseBoolean(Config.getEnv("auto_create_users", "false"));238 public static auto_create_user_from_jwt: boolean = Config.parseBoolean(Config.getEnv("auto_create_user_from_jwt", "false"));239 public static auto_create_domains: string[] = Config.parseArray(Config.getEnv("auto_create_domains", ""));240 public static persist_user_impersonation: boolean = Config.parseBoolean(Config.getEnv("persist_user_impersonation", "true"));241 public static ping_clients_interval: number = parseInt(Config.getEnv("ping_clients_interval", (10000).toString())); // 12 seconds242 public static allow_personal_nodered: boolean = Config.parseBoolean(Config.getEnv("allow_personal_nodered", "false"));243 public static use_ingress_beta1_syntax: boolean = Config.parseBoolean(Config.getEnv("use_ingress_beta1_syntax", "true"));244 public static auto_create_personal_nodered_group: boolean = Config.parseBoolean(Config.getEnv("auto_create_personal_nodered_group", "false"));245 public static auto_create_personal_noderedapi_group: boolean = Config.parseBoolean(Config.getEnv("auto_create_personal_noderedapi_group", "false"));246 public static force_add_admins: boolean = Config.parseBoolean(Config.getEnv("force_add_admins", "true"));247 public static tls_crt: string = Config.getEnv("tls_crt", "");248 public static tls_key: string = Config.getEnv("tls_key", "");249 public static tls_ca: string = Config.getEnv("tls_ca", "");250 public static tls_passphrase: string = Config.getEnv("tls_passphrase", "");251 public static cache_store_type: string = Config.getEnv("cache_store_type", "memory");252 public static cache_store_max: number = parseInt(Config.getEnv("cache_store_max", "1000"));253 public static cache_store_ttl_seconds: number = parseInt(Config.getEnv("cache_store_ttl_seconds", "3600"));254 public static cache_store_redis_host: string = Config.getEnv("cache_store_redis_host", "");255 public static cache_store_redis_port: number = parseInt(Config.getEnv("cache_store_redis_port", "6379"));256 public static cache_store_redis_password: string = Config.getEnv("cache_store_redis_password", "");257 public static oidc_access_token_ttl: number = parseInt(Config.getEnv("oidc_access_token_ttl", "480")); // 8 hours258 public static oidc_authorization_code_ttl: number = parseInt(Config.getEnv("oidc_authorization_code_ttl", "480")); // 8 hours259 public static oidc_client_credentials_ttl: number = parseInt(Config.getEnv("oidc_client_credentials_ttl", "480")); // 8 hours260 public static oidc_refresh_token_ttl: number = parseInt(Config.getEnv("oidc_refresh_token_ttl", "20160")); // 14 days in seconds261 public static oidc_session_ttl: number = parseInt(Config.getEnv("oidc_session_ttl", "20160")); // 14 days in seconds262 public static oidc_cookie_key: string = Config.getEnv("oidc_cookie_key", "Y6SPiXCxDhAJbN7cbydMw5eX1wIrdy8PiWApqEcguss=");263 public static api_rate_limit: boolean = Config.parseBoolean(Config.getEnv("api_rate_limit", "true"));264 public static api_rate_limit_points: number = parseInt(Config.getEnv("api_rate_limit_points", "20"));265 public static api_rate_limit_duration: number = parseInt(Config.getEnv("api_rate_limit_duration", "1"));266 public static socket_rate_limit: boolean = Config.parseBoolean(Config.getEnv("socket_rate_limit", "true"));267 public static socket_rate_limit_points: number = parseInt(Config.getEnv("socket_rate_limit_points", "30"));268 public static socket_rate_limit_points_disconnect: number = parseInt(Config.getEnv("socket_rate_limit_points_disconnect", "600"));269 public static socket_rate_limit_duration: number = parseInt(Config.getEnv("socket_rate_limit_duration", "1"));270 public static socket_error_rate_limit_points: number = parseInt(Config.getEnv("socket_error_rate_limit_points", "30"));271 public static socket_error_rate_limit_duration: number = parseInt(Config.getEnv("socket_error_rate_limit_duration", "1"));272 public static client_heartbeat_timeout: number = parseInt(Config.getEnv("client_heartbeat_timeout", "60"));273 public static expected_max_roles: number = parseInt(Config.getEnv("expected_max_roles", "20000"));274 public static decorate_roles_fetching_all_roles = Config.parseBoolean(Config.getEnv("decorate_roles_fetching_all_roles", "true"));275 public static max_recursive_group_depth: number = parseInt(Config.getEnv("max_recursive_group_depth", "2"));276 public static update_acl_based_on_groups: boolean = Config.parseBoolean(Config.getEnv("update_acl_based_on_groups", "false"));277 public static multi_tenant: boolean = Config.parseBoolean(Config.getEnv("multi_tenant", "false"));278 public static api_bypass_perm_check: boolean = Config.parseBoolean(Config.getEnv("api_bypass_perm_check", "false"));279 public static websocket_package_size: number = parseInt(Config.getEnv("websocket_package_size", "4096"), 10);280 public static websocket_max_package_count: number = parseInt(Config.getEnv("websocket_max_package_count", "1024"), 10);281 public static websocket_disconnect_out_of_sync: boolean = Config.parseBoolean(Config.getEnv("websocket_disconnect_out_of_sync", "false"));282 public static protocol: string = Config.getEnv("protocol", "http"); // used by personal nodered and baseurl()283 public static port: number = parseInt(Config.getEnv("port", "3000"));284 public static domain: string = Config.getEnv("domain", "localhost"); // sent to website and used in baseurl()285 public static cookie_secret: string = Config.getEnv("cookie_secret", "NLgUIsozJaxO38ze0WuHthfj2eb1eIEu"); // Used to protect cookies286 public static max_ace_count: number = parseInt(Config.getEnv("max_ace_count", "128"), 10);287 public static amqp_reply_expiration: number = parseInt(Config.getEnv("amqp_reply_expiration", (60 * 1000).toString())); // 1 min288 public static amqp_force_queue_prefix: boolean = Config.parseBoolean(Config.getEnv("amqp_force_queue_prefix", "false"));289 public static amqp_force_exchange_prefix: boolean = Config.parseBoolean(Config.getEnv("amqp_force_exchange_prefix", "false"));290 public static amqp_force_sender_has_read: boolean = Config.parseBoolean(Config.getEnv("amqp_force_sender_has_read", "true"));291 public static amqp_force_sender_has_invoke: boolean = Config.parseBoolean(Config.getEnv("amqp_force_sender_has_invoke", "false"));292 public static amqp_force_consumer_has_update: boolean = Config.parseBoolean(Config.getEnv("amqp_force_consumer_has_update", "false"));293 public static amqp_enabled_exchange: boolean = Config.parseBoolean(Config.getEnv("amqp_enabled_exchange", "false"));294 public static amqp_url: string = Config.getEnv("amqp_url", "amqp://localhost"); // used to register queues and by personal nodered295 public static amqp_username: string = Config.getEnv("amqp_username", "guest"); // used to talk wth rabbitmq api296 public static amqp_password: string = Config.getEnv("amqp_password", "guest"); // used to talk wth rabbitmq api297 public static amqp_check_for_consumer: boolean = Config.parseBoolean(Config.getEnv("amqp_check_for_consumer", "true"));298 public static amqp_check_for_consumer_count: boolean = Config.parseBoolean(Config.getEnv("amqp_check_for_consumer_count", "false"));299 public static amqp_default_expiration: number = parseInt(Config.getEnv("amqp_default_expiration", (60 * 1000).toString())); // 1 min300 public static amqp_requeue_time: number = parseInt(Config.getEnv("amqp_requeue_time", "1000")); // 1 seconds 301 public static amqp_dlx: string = Config.getEnv("amqp_dlx", "openflow-dlx"); // Dead letter exchange, used to pickup dead or timeout messages302 public static mongodb_url: string = Config.getEnv("mongodb_url", "mongodb://localhost:27017");303 public static mongodb_db: string = Config.getEnv("mongodb_db", "openflow");304 public static mongodb_minpoolsize: number = parseInt(Config.getEnv("mongodb_minpoolsize", "25"));305 public static skip_history_collections: string = Config.getEnv("skip_history_collections", "");306 public static history_delta_count: number = parseInt(Config.getEnv("history_delta_count", "1000"));307 public static allow_skiphistory: boolean = Config.parseBoolean(Config.getEnv("allow_skiphistory", "true"));308 public static saml_issuer: string = Config.getEnv("saml_issuer", "the-issuer"); // define uri of STS, also sent to personal nodereds309 public static aes_secret: string = Config.getEnv("aes_secret", "");310 public static signing_crt: string = Config.getEnv("signing_crt", "");311 public static singing_key: string = Config.getEnv("singing_key", "");312 public static shorttoken_expires_in: string = Config.getEnv("shorttoken_expires_in", "5m");313 public static longtoken_expires_in: string = Config.getEnv("longtoken_expires_in", "365d");314 public static downloadtoken_expires_in: string = Config.getEnv("downloadtoken_expires_in", "15m");315 public static personalnoderedtoken_expires_in: string = Config.getEnv("personalnoderedtoken_expires_in", "365d");316 // public static nodered_image: string = Config.getEnv("nodered_image", "openiap/nodered");317 public static nodered_images: NoderedImage[] = JSON.parse(Config.getEnv("nodered_images", "[{\"name\":\"Latest Plain Nodered\", \"image\":\"openiap/nodered\"}]"));318 public static saml_federation_metadata: string = Config.getEnv("saml_federation_metadata", "");319 public static api_ws_url: string = Config.getEnv("api_ws_url", "");320 public static nodered_ws_url: string = Config.getEnv("nodered_ws_url", "");321 public static nodered_saml_entrypoint: string = Config.getEnv("nodered_saml_entrypoint", "");322 public static nodered_docker_entrypoints: string = Config.getEnv("nodered_docker_entrypoints", "web");323 public static nodered_docker_certresolver: string = Config.getEnv("nodered_docker_certresolver", "");324 public static namespace: string = Config.getEnv("namespace", ""); // also sent to website 325 public static nodered_domain_schema: string = Config.getEnv("nodered_domain_schema", ""); // also sent to website326 public static nodered_initial_liveness_delay: number = parseInt(Config.getEnv("nodered_initial_liveness_delay", "60"));327 public static nodered_allow_nodeselector: boolean = Config.parseBoolean(Config.getEnv("nodered_allow_nodeselector", "false"));328 public static nodered_requests_memory: string = Config.getEnv("nodered_requests_memory", "");329 public static nodered_requests_cpu: string = Config.getEnv("nodered_requests_cpu", ""); // 1000m = 1vCPU330 public static nodered_limits_memory: string = Config.getEnv("nodered_limits_memory", "");331 public static nodered_limits_cpu: string = Config.getEnv("nodered_limits_cpu", ""); // 1000m = 1vCPU332 public static nodered_liveness_failurethreshold: number = parseInt(Config.getEnv("nodered_liveness_failurethreshold", "5"));333 public static nodered_liveness_timeoutseconds: number = parseInt(Config.getEnv("nodered_liveness_timeoutseconds", "5"));334 public static noderedcatalogues: string = Config.getEnv("noderedcatalogues", "");335 public static prometheus_measure_nodeid: boolean = Config.parseBoolean(Config.getEnv("prometheus_measure_nodeid", "false"));336 public static prometheus_measure_queued_messages: boolean = Config.parseBoolean(Config.getEnv("prometheus_measure_queued_messages", "false"));337 public static prometheus_measure__mongodb_watch: boolean = Config.parseBoolean(Config.getEnv("prometheus_measure__mongodb_watch", "false"));338 public static prometheus_measure_onlineuser: boolean = Config.parseBoolean(Config.getEnv("prometheus_measure_onlineuser", "false"));339 public static enable_analytics: boolean = Config.parseBoolean(Config.getEnv("enable_analytics", "true"));340 public static otel_debug_log: boolean = Config.parseBoolean(Config.getEnv("otel_debug_log", "false"));341 public static otel_warn_log: boolean = Config.parseBoolean(Config.getEnv("otel_warn_log", "false"));342 public static otel_err_log: boolean = Config.parseBoolean(Config.getEnv("otel_err_log", "false"));343 public static otel_trace_url: string = Config.getEnv("otel_trace_url", "");344 public static otel_metric_url: string = Config.getEnv("otel_metric_url", "");345 public static otel_trace_interval: number = parseInt(Config.getEnv("otel_trace_interval", "5000"));346 public static otel_metric_interval: number = parseInt(Config.getEnv("otel_metric_interval", "5000"));347 public static otel_trace_pingclients: boolean = Config.parseBoolean(Config.getEnv("otel_trace_pingclients", "false"));348 public static otel_trace_dashboardauth: boolean = Config.parseBoolean(Config.getEnv("otel_trace_dashboardauth", "false"));349 public static otel_trace_include_query: boolean = Config.parseBoolean(Config.getEnv("otel_trace_include_query", "false"));350 351 public static validate_user_form: string = Config.getEnv("validate_user_form", "");352 public static baseurl(): string {353 let result: string = "";354 if (Config.tls_crt != '' && Config.tls_key != '') {355 result = "https://" + Config.domain;356 } else {357 result = Config.protocol + "://" + Config.domain;358 }359 if (Config.port != 80 && Config.port != 443 && Config.port != 3000) {360 result = result + ":" + Config.port + "/";361 } else { result = result + "/"; }362 return result;363 }364 public static basewsurl(): string {365 let result: string = "";366 if (Config.tls_crt != '' && Config.tls_key != '') {367 result = "wss://" + Config.domain;368 } else if (Config.protocol == "http") {369 result = "ws://" + Config.domain;370 } else {371 result = "wss://" + Config.domain;372 }373 if (Config.port != 80 && Config.port != 443 && Config.port != 3000) {374 result = result + ":" + Config.port + "/";375 } else { result = result + "/"; }376 return result;377 }378 public static getEnv(name: string, defaultvalue: string): string {379 let value: any = process.env[name];380 if (!value || value === "") { value = defaultvalue; }381 return value;382 }383 public static async parse_federation_metadata(url: string): Promise<any> {384 // if anything throws, we retry385 return promiseRetry(async () => {386 const reader: any = await fetch({ url });387 if (NoderedUtil.IsNullUndefinded(reader)) { throw new Error("Failed getting result"); return; }388 const config: any = toPassportConfig(reader);389 // we need this, for Office 365 :-/390 if (reader.signingCerts && reader.signingCerts.length > 1) {391 config.cert = reader.signingCerts;392 }...
getenv.js
Source:getenv.js
1var assert = require('assert');2var getenv = require('../lib/getenv');3// Setting env vars for testing4process.env.TEST_GETENV_EMPTY_STRING = '';5process.env.TEST_GETENV_STRING = 'This is a string.';6process.env.TEST_GETENV_INT1 = '10';7process.env.TEST_GETENV_INT2 = '0';8process.env.TEST_GETENV_INT3 = '-1';9process.env.TEST_GETENV_FLOAT1 = '12.3';10process.env.TEST_GETENV_FLOAT2 = '0.0';11process.env.TEST_GETENV_INFINITY1 = Infinity;12process.env.TEST_GETENV_INFINITY2 = -Infinity;13process.env.TEST_GETENV_FALSE = 'false';14process.env.TEST_GETENV_TRUE = 'true';15process.env.TEST_GETENV_NOT_REALLY_TRUE = '1';16process.env.TEST_GETENV_NOT_REALLY_FALSE = '0';17process.env.TEST_GETENV_WRONG_NUMBER_INPUT = '3 test';18process.env.TEST_GETENV_STRING_ARRAY1 = 'one';19process.env.TEST_GETENV_STRING_ARRAY2 = 'one, two ,three , four';20process.env.TEST_GETENV_STRING_ARRAY3 = 'one, two,';21process.env.TEST_GETENV_STRING_ARRAY4 = ' ';22process.env.TEST_GETENV_STRING_ARRAY5 = 'one;two:three,four';23process.env.TEST_GETENV_INT_ARRAY = '1,2, 3';24process.env.TEST_GETENV_INT_ARRAY_INVALID1 = '1, 2.2, 3';25process.env.TEST_GETENV_INT_ARRAY_INVALID2 = '1, true, 3';26process.env.TEST_GETENV_INT_ARRAY_INVALID3 = '1, abc, 3';27process.env.TEST_GETENV_FLOAT_ARRAY = '1.9,2, 3e5';28process.env.TEST_GETENV_FLOAT_ARRAY_INVALID1 = '1.9,true, 3e5';29process.env.TEST_GETENV_FLOAT_ARRAY_INVALID2 = '1.9, abc, 3e5';30process.env.TEST_GETENV_FLOAT_ARRAY_INVALID3 = '1.9, Infinity, 3e5';31process.env.TEST_GETENV_BOOL_ARRAY = 'true, false, true';32process.env.TEST_GETENV_BOOL_ARRAY_INVALID1 = 'true, 1, true';33process.env.TEST_GETENV_BOOL_ARRAY_INVALID2 = 'true, 1.2, true';34process.env.TEST_GETENV_BOOL_ARRAY_INVALID3 = 'true, abc, true';35process.env.TEST_GETENV_URL_1 = 'tcp://localhost:80';36process.env.TEST_GETENV_URL_2 = 'tcp://localhost:2993';37process.env.TEST_GETENV_URL_3 = 'http://192.162.22.11:2993';38var tests = {};39tests['getenv() same as getenv.string()'] = function() {40 var data = [{41 varName: 'TEST_GETENV_STRING',42 expected: 'This is a string.'43 }, {44 varName: 'TEST_GETENV_EMPTY_STRING',45 expected: ''46 }];47 data.forEach(function(item) {48 var stringVar1 = getenv(item.varName);49 var stringVar2 = getenv.string(item.varName);50 assert.strictEqual(stringVar1, stringVar2);51 });52};53tests['getenv.string() valid input'] = function() {54 var data = [{55 varName: 'TEST_GETENV_STRING',56 expected: 'This is a string.'57 }, {58 varName: 'TEST_GETENV_EMPTY_STRING',59 expected: ''60 }];61 data.forEach(function(item) {62 var stringVar = getenv.string(item.varName);63 assert.strictEqual(stringVar, item.expected);64 });65};66tests['getenv.string() nonexistent variable'] = function() {67 assert.throws(function() {68 getenv('TEST_GETENV_NONEXISTENT');69 });70 assert.throws(function() {71 getenv.string('TEST_GETENV_NONEXISTENT');72 });73};74tests['getenv.string() nonexistent variable with fallback'] = function() {75 var expect = 'fallback';76 var stringVar = getenv.string('TEST_GETENV_NONEXISTENT', expect);77 assert.strictEqual(stringVar, expect);78 stringVar = getenv('TEST_GETENV_NONEXISTENT', expect);79 assert.strictEqual(stringVar, expect);80};81tests['getenv.int() valid input'] = function() {82 var data = [{83 varName: 'TEST_GETENV_INT1',84 expected: 1085 }, {86 //use default87 varName: 'TEST_GETENV_INT2',88 expected: 089 }, {90 //use default91 varName: 'TEST_GETENV_INT3',92 expected: -193 }];94 data.forEach(function(item) {95 var intVar = getenv.int(item.varName);96 assert.strictEqual(intVar, item.expected);97 });98};99tests['getenv.int() invalid input'] = function() {100 var data = [101 { varName: 'TEST_GETENV_FLOAT' },102 { varName: 'TEST_GETENV_WRONG_NUMBER_INPUT' },103 { varName: 'TEST_GETENV_EMPTY_STRING' },104 { varName: 'TEST_GETENV_INFINITY1' },105 { varName: 'TEST_GETENV_INFINITY2' }106 ];107 data.forEach(function(item) {108 assert.throws(function() {109 var intVar = getenv.int(item.varName);110 });111 });112};113tests['getenv.int() nonexistent variable'] = function() {114 assert.throws(function() {115 getenv.int('TEST_GETENV_NONEXISTENT');116 });117};118tests['getenv.int() nonexistent variable with fallback'] = function() {119 var expect = 10;120 var intVar = getenv.int('TEST_GETENV_NONEXISTENT', expect);121 assert.strictEqual(intVar, expect);122};123tests['getenv.float() valid input'] = function() {124 var data = [{125 varName: 'TEST_GETENV_FLOAT1',126 expected: 12.3127 }, {128 varName: 'TEST_GETENV_FLOAT2',129 expected: 0.0130 }];131 data.forEach(function(item) {132 var floatVar = getenv.float(item.varName);133 assert.strictEqual(floatVar, item.expected);134 });135};136tests['getenv.float() invalid input'] = function() {137 var data = [138 { varName: 'TEST_GETENV_WRONG_NUMBER_INPUT' },139 { varName: 'TEST_GETENV_EMPTY_STRING' },140 { varName: 'TEST_GETENV_INFINITY1' },141 { varName: 'TEST_GETENV_INFINITY2' }142 ];143 data.forEach(function(item) {144 assert.throws(function() {145 var floatVar = getenv.float(item.varName);146 });147 });148};149tests['getenv.float() nonexistent variable'] = function() {150 assert.throws(function() {151 getenv.float('TEST_GETENV_NONEXISTENT');152 });153};154tests['getenv.float() nonexistent variable with fallback'] = function() {155 var expect = 2.2;156 var floatVar = getenv.float('TEST_GETENV_NONEXISTENT', expect);157 assert.strictEqual(floatVar, expect);158};159tests['getenv.bool() valid input'] = function() {160 var data = [{161 varName: 'TEST_GETENV_FALSE',162 expected: false163 }, {164 varName: 'TEST_GETENV_TRUE',165 expected: true166 }];167 data.forEach(function(item) {168 var boolVar = getenv.bool(item.varName);169 assert.strictEqual(boolVar, item.expected);170 });171};172tests['getenv.bool() invalid input'] = function() {173 var data = [174 { varName: 'TEST_GETENV_STRING' },175 { varName: 'TEST_GETENV_EMPTY_STRING' },176 { varName: 'TEST_GETENV_NOT_REALLY_TRUE' },177 { varName: 'TEST_GETENV_NOT_REALLY_FALSE' }178 ];179 data.forEach(function(item) {180 assert.throws(function() {181 var boolVar = getenv.bool(item.varName);182 });183 });184};185tests['getenv.boolish() valid input'] = function() {186 var data = [{187 varName: 'TEST_GETENV_FALSE',188 expected: false189 }, {190 varName: 'TEST_GETENV_TRUE',191 expected: true192 }, {193 varName: 'TEST_GETENV_NOT_REALLY_FALSE',194 expected: false195 }, {196 varName: 'TEST_GETENV_NOT_REALLY_TRUE',197 expected: true198 }];199 data.forEach(function(item) {200 var boolVar = getenv.boolish(item.varName);201 assert.strictEqual(boolVar, item.expected);202 });203};204tests['getenv.boolish() invalid input'] = function() {205 var data = [206 { varName: 'TEST_GETENV_STRING' },207 { varName: 'TEST_GETENV_EMPTY_STRING' }208 ];209 data.forEach(function(item) {210 assert.throws(function() {211 var boolVar = getenv.boolish(item.varName);212 });213 });214};215tests['getenv.bool() nonexistent variable'] = function() {216 assert.throws(function() {217 getenv.bool('TEST_GETENV_NONEXISTENT');218 });219};220tests['getenv.bool() nonexistent variable with fallback'] = function() {221 var expect = true;222 var boolVar = getenv.bool('TEST_GETENV_NONEXISTENT', expect);223 assert.strictEqual(boolVar, expect);224};225tests['getenv.array() valid string (default) input'] = function() {226 var data = [{227 varName: 'TEST_GETENV_EMPTY_STRING',228 expected: ['']229 }, {230 varName: 'TEST_GETENV_STRING_ARRAY1',231 expected: ['one']232 }, {233 varName: 'TEST_GETENV_STRING_ARRAY2',234 expected: ['one', 'two', 'three', 'four']235 }, {236 varName: 'TEST_GETENV_STRING_ARRAY3',237 expected: ['one', 'two', '']238 }, {239 varName: 'TEST_GETENV_STRING_ARRAY4',240 expected: [' ']241 }, {242 varName: 'TEST_GETENV_STRING_ARRAY5',243 expected: ['one;two:three', 'four']244 }];245 data.forEach(function(item) {246 var arrayVar = getenv.array(item.varName);247 assert.deepEqual(arrayVar, item.expected);248 });249};250tests['getenv.array() valid integer input'] = function() {251 var data = [{252 varName: 'TEST_GETENV_INT_ARRAY',253 expected: [1, 2, 3]254 }];255 data.forEach(function(item) {256 var arrayVar = getenv.array(item.varName, 'int');257 // @TODO Something like https://github.com/joyent/node/issues/594 would be258 // handy.259 assert.strictEqual(arrayVar.length, item.expected.length);260 for (var i = 0; i < item.expected.length; i++) {261 assert.strictEqual(arrayVar[i], item.expected[i]);262 }263 });264};265tests['getenv.array() invalid integer input'] = function() {266 var data = [267 { varName: 'TEST_GETENV_INT_ARRAY_INVALID1' },268 { varName: 'TEST_GETENV_INT_ARRAY_INVALID2' },269 { varName: 'TEST_GETENV_INT_ARRAY_INVALID3' }270 ];271 data.forEach(function(item) {272 assert.throws(function() {273 var data = getenv.array(item.varName, 'int');274 });275 });276};277tests['getenv.array() valid float input'] = function() {278 var data = [{279 varName: 'TEST_GETENV_FLOAT_ARRAY',280 expected: [1.9, 2, 3e5]281 }];282 data.forEach(function(item) {283 var arrayVar = getenv.array(item.varName, 'float');284 assert.strictEqual(arrayVar.length, item.expected.length);285 for (var i = 0; i < item.expected.length; i++) {286 assert.strictEqual(arrayVar[i], item.expected[i]);287 }288 });289};290tests['getenv.array() invalid float input'] = function() {291 var data = [292 { varName: 'TEST_GETENV_FLOAT_ARRAY_INVALID1' },293 { varName: 'TEST_GETENV_FLOAT_ARRAY_INVALID2' },294 { varName: 'TEST_GETENV_FLOAT_ARRAY_INVALID3' }295 ];296 data.forEach(function(item) {297 assert.throws(function() {298 var data = getenv.array(item.varName, 'float');299 });300 });301};302tests['getenv.array() valid bool input'] = function() {303 var data = [{304 varName: 'TEST_GETENV_BOOL_ARRAY',305 expected: [true, false, true]306 }];307 data.forEach(function(item) {308 var arrayVar = getenv.array(item.varName, 'bool');309 assert.strictEqual(arrayVar.length, item.expected.length);310 for (var i = 0; i < item.expected.length; i++) {311 assert.strictEqual(arrayVar[i], item.expected[i]);312 }313 });314};315tests['getenv.array() invalid bool input'] = function() {316 var data = [317 { varName: 'TEST_GETENV_BOOL_ARRAY_INVALID1' },318 { varName: 'TEST_GETENV_BOOL_ARRAY_INVALID2' },319 { varName: 'TEST_GETENV_BOOL_ARRAY_INVALID3' }320 ];321 data.forEach(function(item) {322 assert.throws(function() {323 var data = getenv.array(item.varName, 'bool');324 });325 });326};327tests['getenv.array() nonexistent variable'] = function() {328 assert.throws(function() {329 getenv.array('TEST_GETENV_NONEXISTENT');330 });331};332tests['getenv.array() nonexistent variable with fallback'] = function() {333 var expect = ['A', 'B', 'C'];334 var arrayVar = getenv.array('TEST_GETENV_NONEXISTENT', 'string', expect);335 assert.deepEqual(arrayVar, expect);336};337tests['getenv.array() nonexistent type'] = function() {338 assert.throws(function() {339 getenv.array('TEST_GETENV_STRING_ARRAY1', 'unknown');340 });341};342tests['getenv.multi([string]) multiple env vars'] = function() {343 var spec = {344 foo: 'TEST_GETENV_STRING' // throws when nonexistant345 };346 var config = getenv.multi(spec);347 var expect = {348 foo: process.env.TEST_GETENV_STRING349 };350 assert.deepEqual(expect, config);351};352tests['getenv([string]) multiple env vars shortcut'] = function() {353 var spec = {354 foo: 'TEST_GETENV_STRING' // throws when nonexistant355 };356 var config = getenv(spec);357 var expect = {358 foo: process.env.TEST_GETENV_STRING359 };360 assert.deepEqual(expect, config);361};362tests['getenv.multi([string/throw]) multiple env vars'] = function() {363 var spec = {364 foo: 'TEST_GETENV_NONEXISTENT' // throws when nonexistant365 };366 assert.throws(function() {367 var config = getenv.multi(spec);368 });369};370tests['getenv.multi([string/typecast]) multiple env vars'] = function() {371 var spec = {372 foo: ['TEST_GETENV_STRING', undefined, 'string']373 };374 var config = getenv.multi(spec);375 var expect = {376 foo: process.env.TEST_GETENV_STRING377 };378 assert.deepEqual(expect, config);379};380tests['getenv.multi([string/typecast/defaultval]) multiple env vars'] = function() {381 var spec = {382 foo: ['TEST_GETENV_NONEXISTENT', 'default', 'string'] // throws when nonexistant383 };384 var config = getenv.multi(spec);385 var expect = {386 foo: 'default'387 };388 assert.deepEqual(expect, config);389};390tests['getenv.multi([string/typecast/throw]) multiple env vars'] = function() {391 var spec = {392 foo: ['TEST_GETENV_NONEXISTENT', undefined, 'string'] // throws when nonexistant393 };394 assert.throws(function() {395 var config = getenv.multi(spec);396 });397};398tests['getenv.multi([string/defaultval]) multiple env vars'] = function() {399 var spec = {400 foo: ['TEST_GETENV_STRING', 'default'] // throws when nonexistant401 };402 var config = getenv.multi(spec);403 var expect = {404 foo: process.env.TEST_GETENV_STRING405 };406 assert.deepEqual(expect, config);407};408tests['getenv.multi([string/defaultval/throw]) multiple env vars'] = function() {409 var spec = {410 foo: ['TEST_GETENV_NONEXISTENT', 'default'] // throws when nonexistant411 };412 var config = getenv.multi(spec);413 var expect = {414 foo: 'default'415 };416 assert.deepEqual(expect, config);417};418tests['getenv.multi([string/single]) multiple env vars'] = function() {419 var spec = {420 foo: ['TEST_GETENV_STRING'] // throws when nonexistant421 };422 var config = getenv.multi(spec);423 var expect = {424 foo: process.env.TEST_GETENV_STRING425 };426 assert.deepEqual(expect, config);427};428tests['getenv.multi([string/single/throw]) multiple env vars'] = function() {429 var spec = {430 foo: ['TEST_GETENV_NONEXISTENT'] // throws when nonexistant431 };432 assert.throws(function() {433 var config = getenv.multi(spec);434 });435};436tests['getenv.url() valid input'] = function() {437 var expected = [438 {hostname: 'localhost', port: '80', protocol: 'tcp:'},439 {hostname: 'localhost', port: '2993', protocol: 'tcp:'},440 {hostname: '192.162.22.11', port: '2993', protocol: 'http:'},441 ];442 var prefix = 'TEST_GETENV_URL_';443 expected.forEach(function(expectation, i) {444 var parsed = getenv.url(prefix + (i + 1));445 var actual = Object.keys(expectation).reduce(function(h, key) {446 h[key] = parsed[key];447 return h;448 }, {});449 assert.deepEqual(actual, expectation);450 });451};452Object.keys(tests).forEach(function(key) {453 console.log('Test: %s', key);454 tests[key]();...
index.js
Source:index.js
...32 optStr: 'foofoo',33 };34 it('throws an error if setEnv hasnt been called with an object', function() {35 const getEnv = tsEnv(schema);36 assert.throws(() => getEnv('str'));37 getEnv.setEnv('blah');38 assert.throws(() => getEnv('str'));39 });40 it('accepts a string', function() {41 const getEnv = tsEnv(schema);42 getEnv.setEnv(validProcessEnv);43 assert.doesNotThrow(() => getEnv('str'));44 });45 it('returns the value of the environment variable from process.env, properly coerced', function() {46 const getEnv = tsEnv(schema);47 getEnv.setEnv(validProcessEnv);48 assert.equal(getEnv('str'), 'bar');49 assert.equal(getEnv('num'), 2);50 });51 it('returns the value of optional environment variables', function() {52 const getEnv = tsEnv(schema);53 getEnv.setEnv(validProcessEnv);54 assert.equal(getEnv('optStr'), 'foofoo');55 });56 it('throws if requested environment variable is not defined in schema', function() {57 const getEnv = tsEnv(schema);58 getEnv.setEnv(validProcessEnv);59 assert.throws(() => getEnv('baz'));60 });61 it('throws if any variable in process.env cannot be coerced to the correct type', function() {62 const getEnv = tsEnv(schema);63 getEnv.setEnv(Object.assign({ }, validProcessEnv, { num: 'two' }));64 assert.throws(() => getEnv('str'));65 });66 it('strips unknown environment variables', function() {67 const getEnv = tsEnv(schema);68 getEnv.setEnv(Object.assign({ foo: 'barbar' }, validProcessEnv));69 assert.throws(() => getEnv('foo'));70 });71 it('throws if process.env is missing environment variables in schema', function() {72 const missingEnv = Object.assign({}, validProcessEnv);73 delete missingEnv.str;74 const getEnv = tsEnv(schema);75 getEnv.setEnv(missingEnv);76 assert.throws(() => getEnv('ENV'));77 });78 it('does not throw if optional environment variables in schema are not in process.env', function() {79 const optMissingEnv = Object.assign({}, validProcessEnv);80 delete optMissingEnv.foofoo;81 const getEnv = tsEnv(schema);82 getEnv.setEnv(optMissingEnv);83 assert.doesNotThrow(() => getEnv('ENV'));84 });85 it('throws if forbidden environment variables in schema are in process.env', function() {86 const getEnv = tsEnv(schema);87 getEnv.setEnv(Object.assign({ forbStr: 'bar' }, validProcessEnv));88 assert.throws(() => getEnv('str'));89 });90 it('does obeys default values set in the schema', function() {91 const getEnv = tsEnv(schema.keys({ str: Joi.string().default('baz') }));92 getEnv.setEnv(validProcessEnv);93 assert.equal(getEnv('str'), 'baz');94 });95 it('requires process.env.NODE_ENV to equal \'test\', \'local\', \'demo\', \'development\', \'staging\', \'production\'', function() {96 let getEnv = tsEnv(schema);97 getEnv.setEnv(Object.assign({ }, validProcessEnv, { ENV: 'foo' }));98 assert.throws(() => getEnv('str'));99 getEnv = tsEnv(schema);100 getEnv.setEnv(Object.assign({ }, validProcessEnv, { ENV: 'test' }));101 assert.doesNotThrow(() => getEnv('str'));102 getEnv = tsEnv(schema);103 getEnv.setEnv(Object.assign({ }, validProcessEnv, { ENV: 'local' }));104 assert.doesNotThrow(() => getEnv('str'));105 getEnv = tsEnv(schema);106 getEnv.setEnv(Object.assign({ }, validProcessEnv, { ENV: 'demo' }));107 assert.doesNotThrow(() => getEnv('str'));108 getEnv = tsEnv(schema);109 getEnv.setEnv(Object.assign({ }, validProcessEnv, { ENV: 'development' }));110 assert.doesNotThrow(() => getEnv('str'));111 getEnv = tsEnv(schema);112 getEnv.setEnv(Object.assign({ }, validProcessEnv, { ENV: 'staging' }));113 assert.doesNotThrow(() => getEnv('str'));114 getEnv = tsEnv(schema);115 getEnv.setEnv(Object.assign({ }, validProcessEnv, { ENV: 'production' }));116 assert.doesNotThrow(() => getEnv('str'));117 });118 it('requires process.env.SERVICE_NAME to be a non-empty string', function() {119 let getEnv = tsEnv(schema);120 getEnv.setEnv(Object.assign({ }, validProcessEnv, { SERVICE_NAME: '' }));121 assert.throws(() => getEnv('str'));122 getEnv = tsEnv(schema);123 getEnv.setEnv(Object.assign({ }, validProcessEnv, { SERVICE_NAME: 'foo' }));124 assert.doesNotThrow(() => getEnv('str'));125 });126 it('requires process.env.TENANT to be a non-empty string', function() {127 let getEnv = tsEnv(schema);128 getEnv.setEnv(Object.assign({ }, validProcessEnv, { TENANT: '' }));129 assert.throws(() => getEnv('str'));130 getEnv = tsEnv(schema);131 getEnv.setEnv(Object.assign({ }, validProcessEnv, { TENANT: 'foo' }));132 assert.doesNotThrow(() => getEnv('str'));133 });134 describe('in test mode', function(){135 const partiallyValidProcessEnv = {136 ENV: 'production',137 SERVICE_NAME: 'foo',138 TENANT: 'multi',139 num: '2',140 optStr: 'foofoo',141 };142 it('returns the value of environment variable which have been set, properly coerced', function() {143 const getEnv = tsEnv(schema);144 getEnv.enterTestMode(partiallyValidProcessEnv);145 assert.equal(getEnv('num'), 2);146 });147 it('throws if value of requested environment variable has not been set', function() {148 const getEnv = tsEnv(schema);149 getEnv.enterTestMode(partiallyValidProcessEnv);150 assert.throws(() => getEnv('str'));151 });152 it('throws if requested environment variable is not defined in schema', function() {153 const getEnv = tsEnv(schema);154 getEnv.enterTestMode(partiallyValidProcessEnv);155 assert.throws(() => getEnv('baz'));156 });157 it('throws if requested variable in process.env cannot be coerced to the correct type', function() {158 const getEnv = tsEnv(schema);159 getEnv.enterTestMode(Object.assign({ }, validProcessEnv, { num: 'two' }));160 assert.throws(() => getEnv('num'));161 });162 it('strips unknown environment variables', function() {163 const getEnv = tsEnv(schema);164 getEnv.enterTestMode(Object.assign({ foo: 'barbar' }, validProcessEnv));165 assert.throws(() => getEnv('foo'));166 });167 it('resets the environment to {} if no argument passed', function() {168 const getEnv = tsEnv(schema);169 getEnv.setEnv(validProcessEnv);170 getEnv.enterTestMode();171 assert.throws(() => getEnv('num'));172 });173 });174 });...
getEnvSpec.js
Source:getEnvSpec.js
...16 * with this program. If not, see <http://www.gnu.org/licenses/>.17 */18import fakeENV from 'helpers/fakeENV'19import getEnv from 'jsx/assignments/GradeSummary/getEnv'20QUnit.module('GradeSummary getEnv()', suiteHooks => {21 suiteHooks.beforeEach(() => {22 fakeENV.setup({23 ASSIGNMENT: {24 course_id: '1201',25 id: '2301',26 muted: true,27 grades_published: false,28 title: 'Example Assignment'29 },30 CURRENT_USER: {31 can_view_grader_identities: true,32 can_view_student_identities: false,33 grader_id: 'admin',34 id: '1100'35 },36 FINAL_GRADER: {37 grader_id: 'teach',38 id: '1105'39 },40 GRADERS: [41 {grader_name: 'Charlie Xi', id: '4502', user_id: '1103'},42 {grader_name: 'Adam Jones', id: '4503', user_id: '1101'},43 {grader_name: 'Betty Ford', id: '4501', user_id: '1102'}44 ]45 })46 })47 suiteHooks.afterEach(() => {48 fakeENV.teardown()49 })50 QUnit.module('.assignment', () => {51 test('camel-cases .courseId', () => {52 strictEqual(getEnv().assignment.courseId, '1201')53 })54 test('includes .id', () => {55 strictEqual(getEnv().assignment.id, '2301')56 })57 test('includes .muted', () => {58 strictEqual(getEnv().assignment.muted, true)59 })60 test('camel-cases .gradesPublished', () => {61 strictEqual(getEnv().assignment.gradesPublished, false)62 })63 test('includes .title', () => {64 strictEqual(getEnv().assignment.title, 'Example Assignment')65 })66 })67 QUnit.module('.currentUser', () => {68 test('camel-cases .canViewGraderIdentities', () => {69 strictEqual(getEnv().currentUser.canViewGraderIdentities, true)70 })71 test('camel-cases .canViewStudentIdentities', () => {72 strictEqual(getEnv().currentUser.canViewStudentIdentities, false)73 })74 test('camel-cases .graderId', () => {75 equal(getEnv().currentUser.graderId, 'admin')76 })77 test('defaults .graderId to "FINAL_GRADER" when the user is the final grader', () => {78 ENV.CURRENT_USER.id = '1105'79 delete ENV.FINAL_GRADER.grader_id80 delete ENV.CURRENT_USER.grader_id81 strictEqual(getEnv().currentUser.graderId, 'FINAL_GRADER')82 })83 test('defaults .graderId to "CURRENT_USER" when the user is not the final grader', () => {84 // The user is likely an Admin in this scenario.85 delete ENV.FINAL_GRADER.grader_id86 delete ENV.CURRENT_USER.grader_id87 ENV.CURRENT_USER.id = '1100'88 strictEqual(getEnv().currentUser.graderId, 'CURRENT_USER')89 })90 test('includes .id', () => {91 strictEqual(getEnv().currentUser.id, '1100')92 })93 })94 QUnit.module('.finalGrader', () => {95 test('camel-cases .graderId', () => {96 equal(getEnv().finalGrader.graderId, 'teach')97 })98 test('defaults .graderId to "FINAL_GRADER"', () => {99 delete ENV.FINAL_GRADER.grader_id100 strictEqual(getEnv().finalGrader.graderId, 'FINAL_GRADER')101 })102 test('includes .id', () => {103 strictEqual(getEnv().finalGrader.id, '1105')104 })105 test('is null when there is no final grader', () => {106 delete ENV.FINAL_GRADER107 strictEqual(getEnv().finalGrader, null)108 })109 })110 QUnit.module('.graders', () => {111 QUnit.module('when graders are not anonymous', () => {112 test('includes all GRADERS', () => {113 strictEqual(getEnv().graders.length, 3)114 })115 test('includes .id', () => {116 const ids = getEnv()117 .graders.map(grader => grader.id)118 .sort()119 deepEqual(ids, ['4501', '4502', '4503'])120 })121 test('camel-cases .graderId on graders', () => {122 const graderIds = getEnv()123 .graders.map(grader => grader.graderId)124 .sort()125 deepEqual(graderIds, ['1101', '1102', '1103'])126 })127 test('sorts graders by .graderId', () => {128 const graderIds = getEnv().graders.map(grader => grader.graderId)129 deepEqual(graderIds, ['1101', '1102', '1103'])130 })131 test('camel-cases .graderName', () => {132 const graderNames = getEnv().graders.map(grader => grader.graderName)133 deepEqual(graderNames, ['Adam Jones', 'Betty Ford', 'Charlie Xi'])134 })135 })136 QUnit.module('when graders are anonymous', hooks => {137 hooks.beforeEach(() => {138 ENV.GRADERS = [139 {anonymous_id: 'h2asd', id: '4502'},140 {anonymous_id: 'abcde', id: '4503'},141 {anonymous_id: 'b01ng', id: '4501'}142 ]143 })144 test('includes all GRADERS', () => {145 strictEqual(getEnv().graders.length, 3)146 })147 test('includes .id', () => {148 const ids = getEnv()149 .graders.map(grader => grader.id)150 .sort()151 deepEqual(ids, ['4501', '4502', '4503'])152 })153 test('uses .anonymous_id as .graderId', () => {154 const graderIds = getEnv()155 .graders.map(grader => grader.graderId)156 .sort()157 deepEqual(graderIds, ['abcde', 'b01ng', 'h2asd'])158 })159 test('sorts graders by the anonymous .graderId', () => {160 const graderIds = getEnv().graders.map(grader => grader.graderId)161 deepEqual(graderIds, ['abcde', 'b01ng', 'h2asd'])162 })163 test('assigns enumerated names', () => {164 const graderNames = getEnv().graders.map(grader => grader.graderName)165 deepEqual(graderNames, ['Grader 1', 'Grader 2', 'Grader 3'])166 })167 })168 })...
AppConfig.ts
Source:AppConfig.ts
1const getEnv = <T>(variableName: string, fallback: T = null, parse?: boolean): T => {2 try {3 const value = process.env[variableName];4 return (parse ? JSON.parse(value) || value : value || fallback) as T;5 } catch (e) {6 return fallback;7 }8};9// Config details10const AppConfig = {11 ACTIVATION: getEnv<string>('ACTIVATION', '1933241639549000100'),12 ADYEN_ENV: getEnv<string>('ADYEN_ENV', 'test'),13 ADYEN_ORIGIN_KEY: getEnv<string>('ADYEN_ORIGIN_KEY', 'test'),14 ADYEN_PAYMENT_INSTRUMENT_BILL_TYPE: getEnv<string>('ADYEN_PAYMENT_INSTRUMENT_BILL_TYPE', '10108'),15 APP_URL: getEnv<string>('APP_URL', 'http://localhost:8001'),16 APP_VERSION: getEnv<number>('BUILD_ID', 1),17 BENIFY_DISTRIBUTION_CHANNEL_ID: getEnv<string>('BENIFY_DISTRIBUTION_CHANNEL_ID', '581eef0f-c261-4b3c-a760-e7a7a54a486f'),18 BILLING_DISPUTE: getEnv<string>('BILLING_DISPUTE', '3'),19 BONUS_DATA_PRODUCT_VALUE: getEnv<number>('BONUS_DATA_PRODUCT_VALUE', 719434),20 BUSINESS_UNIT: getEnv<string>('BUSINESS_UNIT', '40ae44f2-3185-486e-9c62-b2629728afd0'),21 CDN_API_URL: getEnv<number>('CDN_API_URL', null),22 CLOUD_SEARCH_ORIGIN_KEY: getEnv<number>('CLOUD_SEARCH_ORIGIN_KEY', null),23 COMPLAINT: getEnv<string>('COMPLAINT', '2'),24 DEFAULT_LOCALE: getEnv<string>('DEFAULT_LOCALE', 'en-US'),25 DISMISS_NOTIFICATIONS_ENDPOINT: getEnv<string>('DISMISS_NOTIFICATIONS_ENDPOINT', null),26 DISTRIBUTION_CHANNEL_ID: getEnv<string>('DISTRIBUTION_CHANNEL_ID', '99B5F519-F6DD-405B-B66D-7457BD1944CC'),27 ENABLE_DISCOUNTS: getEnv<string>('ENABLE_DISCOUNTS', 'true'),28 ENVIRONMENT_NAME: getEnv<string>('ENVIRONMENT_NAME', 'tst1'),29 FAILED_PAYMENT: getEnv<string>('FAILED_PAYMENT', '1931356255556000000'),30 FUTURE_ACTIVATION_DATE_ID: getEnv<string>('FUTURE_ACTIVATION_DATE_ID', '2020936572110000009'),31 FUTURE_ACTIVATION_DATE_SERVICE_ATTRIBUTE_ID: getEnv<number>('FUTURE_ACTIVATION_DATE_SERVICE_ATTRIBUTE_ID', 1000280, true),32 GOOGLE_API_PUBLIC_SITE_KEY: getEnv<string>('GOOGLE_API_PUBLIC_SITE_KEY', '6LfMNPkUAAAAAJz385xSk7qizdOyNaGKgoH-BuFE', true),33 INVOICE_DISPUTE: getEnv<string>('INVOICE_DISPUTE', '4'),34 IN_APP_NOTIFICATIONS_ENDPOINT: getEnv<string>('IN_APP_NOTIFICATIONS_ENDPOINT', null),35 KITEWHEEL_LISTENER_ID: getEnv<string>('KITEWHEEL_LISTENER_ID', 'a11160799c8ff37feed1c1d8b9f554a0'),36 MAXIMUM_REQUEST_PAGE_SIZE: getEnv<number>('MAXIMUM_REQUEST_PAGE_SIZE', 3000),37 MECENAT_URL: getEnv<string>('MECENAT_URL', null),38 METADATA_URL: getEnv<string>('METADATA_URL', null),39 MOBILE_NUMBER_PORT: getEnv<string>('MOBILE_NUMBER_PORT', '1927519074395000300'),40 MOBILE_SERVICE_IDENTIFIER: getEnv<string>('MOBILE_SERVICE_IDENTIFIER', '1933241639549000101'),41 OFFER_INSTANCE_ID: getEnv<string>('OFFER_INSTANCE_ID', '1931356255556000003'),42 PAYMENT_DETAILS_URL: getEnv<string>('PAYMENT_DETAILS_URL', null),43 PAYMENT_RETRY_STATUS: getEnv<string>('PAYMENT_RETRY_STATUS', '2026120007625000801'),44 PAYMENT_RETRY_SUCCESS_ID: getEnv<number>('PAYMENT_RETRY_SUCCESS_ID', null, true),45 PAYMENT_RETRY_SUCCESS_ID_OLD_LOGIC: getEnv<number>('PAYMENT_RETRY_SUCCESS_ID', null, true),46 PORT_IN_DATE_ATTRIBUTE_ID: getEnv<number>('PORT_IN_DATE_ATTRIBUTE_ID', 1928471569708000003),47 PORT_IN_INTENT: getEnv<number>('PORT_IN_INTENT', 1000144, true),48 PORT_IN_NUMBER: getEnv<number>('PORT_IN_NUMBER', 1000269),49 PORT_IN_NUMBER_CLOSED_ATTRIBUTE_ID: getEnv<string>('PORT_IN_NUMBER_CLOSED_ATTRIBUTE_ID', null),50 PORT_IN_SERVICE_ATTRIBUTE_ID: getEnv<number>('PORT_IN_SERVICE_ATTRIBUTE_ID', 1003838),51 RAYGUN_API_KEY: getEnv<string>('RAYGUN_API_KEY', 'tJ5Keu02U8ss83hCK5x36g'),52 RELEASE_VERSION: getEnv<number>('RELEASE_ID', 1),53 RIGHT_TO_RETURN_DAYS: getEnv<number>('RIGHT_TO_RETURN_DAYS', 14, true),54 SERVICE_ATTRIBUTE_ID: getEnv<number>('SERVICE_ATTRIBUTE_ID', 1000278),55 SERVICE_IDENTIFIER: getEnv<string>('SERVICE_IDENTIFIER', '1933241639549000103'),56 SERVICE_URL: getEnv<string>('SERVICE_URL', null),57 STUB_URL: getEnv<string>('STUB_URL', null),58 SYSTEM_ID: getEnv<string>('SYSTEM_ID', '40ae44f2-3185-486e-9c62-b2629728afd0'),59 TELE2_AUTH_URL: getEnv<string>('TELE2_AUTH_URL', null),60 TELE2_URL: getEnv<string>('TELE2_URL', null),61 TROUBLE: getEnv<string>('TROUBLE', '1'),62 TROUBLESHOOTER_ENDPOINT: getEnv<string>('TROUBLESHOOTER_ENDPOINT', null),63 UNPAUSE_REASON_CODE: getEnv<number>('UNPAUSE_REASON_CODE', 10315, true),64 USE_RECAPTCHA: getEnv<boolean>('USE_RECAPTCHA', true, true),65 ZEN_DESK_KEY: getEnv<string>('ZEN_DESK_KEY', '894b3c82-08d4-467f-b923-5adc9c7cbeee')66};...
getenv-tests.ts
Source:getenv-tests.ts
1import * as getenv from 'getenv';2import { UrlWithStringQuery } from 'url';3getenv('FOO'); // $ExpectType string4getenv('FOO', 'bar'); // $ExpectType string5getenv('FOO', 123); // $ExpectError6getenv.string('FOO'); // $ExpectType string7getenv.string('FOO', 'bar'); // $ExpectType string8getenv.string('FOO', 123); // $ExpectError9getenv.array('FOO'); // $ExpectType string[]10getenv.array('FOO', 'int'); // $ExpectType number[]11getenv.bool('FOO'); // $ExpectType boolean12getenv.bool('FOO', true); // $ExpectType boolean13getenv.bool('FOO', 'true'); // $ExpectError14getenv.int('FOO'); // $ExpectType number15getenv.int('FOO', 123); // $ExpectType number16getenv.int('FOO', '123'); // $ExpectError17getenv.float('FOO'); // $ExpectType number18getenv.float('FOO', 123.55); // $ExpectType number19getenv.float('FOO', '123.55'); // $ExpectError20getenv.boolish('FOO'); // $ExpectType boolean21getenv.boolish('FOO', false); // $ExpectType boolean22getenv.boolish('FOO', 'false'); // $ExpectError23getenv.url('FOO'); // $ExpectType UrlWithStringQuery24// tslint:disable-next-line:no-object-literal-type-assertion25getenv.url('FOO', {} as UrlWithStringQuery); // $ExpectType UrlWithStringQuery26getenv.url('FOO', {}); // $ExpectError27getenv.array('FOO'); // $ExpectType string[]28getenv.array('FOO', 'int'); // $ExpectType number[]29getenv.array('FOO', 'int', [1]); // $ExpectType number[]30getenv.array('FOO', 'int', ['bar']); // $ExpectError31getenv.multi({ foo: 'BAR' }); // $ExpectType { foo: string; }32getenv.multi({ foo: ['BAR', 'baz'] }); // $ExpectType { foo: string; }33getenv.multi({ foo: ['BAR', 'baz', 'string'] }); // $ExpectType { foo: string; }34getenv.multi({ foo: ['BAR', true, 'bool'] }); // $ExpectType { foo: boolean; }35getenv.multi({ foo: ['BAR', 1.55, 'float'] }); // $ExpectType { foo: number; }36// tslint:disable-next-line:no-object-literal-type-assertion37getenv.multi({ foo: ['BAR', {} as UrlWithStringQuery, 'url'] }); // $ExpectType { foo: UrlWithStringQuery; }...
secrets.ts
Source:secrets.ts
...5 const value = process.env[key];6 return value;7};8// Server9export const ENVIRONMENT = getEnv("NODE_ENV");10export const PRODUCTION = ENVIRONMENT === "production";11export const DEVELOPMENT = ENVIRONMENT === "development";12export const SERVER_ADDRESS = getEnv("SERVER_ADDRESS");13export const SERVER_PORT = getEnv("SERVER_PORT");14export const JWT_SECRET = getEnv("JWT_SECRET");15export const REFRESH_TOKEN_EXP = Number(getEnv("REFRESH_TOKEN_EXP"));16export const ACCESS_TOKEN_EXP = Number(getEnv("ACCESS_TOKEN_EXP"));17export const PROJECT_NAME = getEnv("PROJECT_NAME");18export const PROJECT_VERSION = getEnv("PROJECT_VERSION");19export const RATE_LIMIT_WINDOW_MS = Number(getEnv("RATE_LIMIT_WINDOW_MS") || 1000);20export const RATE_LIMIT_MAX = Number(getEnv("RATE_LIMIT_MAX") || 64);21// UI Avatar22export const AV_BACKGROUND_1 = getEnv("AV_BACKGROUND_1");23export const AV_TEXT_1 = getEnv("AV_TEXT_1");24export const AV_BACKGROUND_2 = getEnv("AV_BACKGROUND_2");25export const AV_TEXT_2 = getEnv("AV_TEXT_2");26// Mongo27const MONGO_USERNAME = getEnv("MONGO_USERNAME");28const MONGO_PASSWORD = encodeURIComponent(getEnv("MONGO_PASSWORD"));29const MONGO_PORT = getEnv("MONGO_PORT");30const MONGO_HOST = getEnv("MONGO_HOST");31export const MONGO_DB = getEnv("MONGO_DB");32export const DATABASE_URI = `mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}/${MONGO_DB}?authSource=admin`;33// Redis34export const REDIS_PORT = Number(getEnv("REDIS_PORT"));35export const REDIS_HOST = getEnv("REDIS_HOST");36export const REDIS_PASSWORD = getEnv("REDIS_PASSWORD");37// Swagger38export const SWAGGER_PATH = getEnv("SWAGGER_PATH");39// Project40export const DEFAULT_USER_PASSWORD = getEnv("DEFAULT_USER_PASSWORD");41//Service42export const APIKEY = getEnv("API_KEY");...
config.js
Source:config.js
...3var path = require('path');4module.exports = {5 port: getEnv.int('PORT', 3000),6 couchDb:{7 username: getEnv('COUCHDB_USERNAME', ''),8 password: getEnv('COUCHDB_PASSWORD', ''),9 url: getEnv('COUCHDB_URL', 'http://127.0.0.1'),10 port: getEnv.int('COUCHDB_PORT', 5984),11 dbName: getEnv('COUCHDB_NAME', 'wfh')12 },13 segment:{14 writeKey: getEnv('SEGMENT_IO_WRITE_KEY', ''),15 },16 slack:{17 token: getEnv('SLACK_TOKEN', ''),18 webhooks:{19 requestTokens: getEnv('SLACK_WEBHOOK_TOKENS', '').split(',')20 }21 },22 auth:{23 admin:{24 password: getEnv('ADMIN_PASSWORD', '$2a$10$oIeQ626Z5yIU7IsvC.1t2.JaegXE1Jn9FaLxF1SfA/jXgQNFah/Wu')25 }26 }...
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var env = strykerParent.getEnv();3var strykerParent = require('stryker-parent');4var env = strykerParent.getEnv();5var strykerParent = require('stryker-parent');6var env = strykerParent.getEnv();7var strykerParent = require('stryker-parent');8var env = strykerParent.getEnv();9var strykerParent = require('stryker-parent');10var env = strykerParent.getEnv();11var strykerParent = require('stryker-parent');12var env = strykerParent.getEnv();13var strykerParent = require('stryker-parent');14var env = strykerParent.getEnv();15var strykerParent = require('stryker-parent');16var env = strykerParent.getEnv();17var strykerParent = require('stryker-parent');18var env = strykerParent.getEnv();19var strykerParent = require('stryker-parent');20var env = strykerParent.getEnv();21var strykerParent = require('stryker-parent');22var env = strykerParent.getEnv();23var strykerParent = require('stryker-parent');24var env = strykerParent.getEnv();25var strykerParent = require('stryker-parent');26var env = strykerParent.getEnv();27var strykerParent = require('stryker-parent');28var env = strykerParent.getEnv();29var strykerParent = require('stry
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var env = strykerParent.getEnv();3var strykerParent = require('stryker-parent');4var env = strykerParent.getEnv();5var strykerParent = require('stryker-parent');6var env = strykerParent.getEnv();7var strykerParent = require('stryker-parent');8var env = strykerParent.getEnv();9var strykerParent = require('stryker-parent');10var env = strykerParent.getEnv();11var strykerParent = require('stryker-parent');12var env = strykerParent.getEnv();13var strykerParent = require('stryker-parent');14var env = strykerParent.getEnv();15var strykerParent = require('stryker-parent');16var env = strykerParent.getEnv();17var strykerParent = require('stryker-parent');18var env = strykerParent.getEnv();19var strykerParent = require('stryker-parent');20var env = strykerParent.getEnv();21var strykerParent = require('stryker-parent');22var env = strykerParent.getEnv();23var strykerParent = require('stryker-parent');24var env = strykerParent.getEnv();25var strykerParent = require('stryker-parent');26var env = strykerParent.getEnv();27var strykerParent = require('
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!