Skip to content

Connectum API Reference / @connectum/core / parseEnvConfig

Function: parseEnvConfig() ​

parseEnvConfig(env?): object

Defined in: packages/core/src/config/envSchema.ts:168

Parse and validate environment configuration

Parameters ​

env? ​

Record<string, string | undefined> = process.env

Returns ​

GRACEFUL_SHUTDOWN_ENABLED ​

GRACEFUL_SHUTDOWN_ENABLED: boolean

Enable graceful shutdown

Default ​

ts
true

GRACEFUL_SHUTDOWN_TIMEOUT_MS ​

GRACEFUL_SHUTDOWN_TIMEOUT_MS: number

Graceful shutdown timeout in milliseconds: a whole number from 0 to 300000, the same kind of value createServer({ shutdown: { timeout } }) accepts (a fraction is rejected here, naming this variable, instead of at server creation). A blank value is rejected rather than read as 0.

Default ​

ts
30000

HTTP_HEALTH_ENABLED ​

HTTP_HEALTH_ENABLED: boolean = BooleanFromStringSchema

Enable HTTP health endpoints (/healthz, /readyz) When disabled, only gRPC healthcheck is available

Default ​

ts
false

HTTP_HEALTH_PATH ​

HTTP_HEALTH_PATH: string

HTTP health endpoint path

Default ​

ts
'/healthz'

LISTEN ​

LISTEN: string

Listen address

Default ​

ts
'0.0.0.0'

LOG_BACKEND ​

LOG_BACKEND: "console" | "otel" | "pino" = LoggerBackendSchema

Logger backend

Default ​

ts
'otel'

LOG_FORMAT ​

LOG_FORMAT: "json" | "pretty" = LogFormatSchema

Log format (json for production, pretty for development)

Default ​

ts
'json'

LOG_LEVEL ​

LOG_LEVEL: "error" | "warn" | "info" | "debug" = LogLevelSchema

Log level

Default ​

ts
'info'

NODE_ENV ​

NODE_ENV: "test" | "production" | "development" = NodeEnvSchema

Node environment

Default ​

ts
'development'

OTEL_EXPORTER_OTLP_ENDPOINT? ​

optional OTEL_EXPORTER_OTLP_ENDPOINT?: string

OpenTelemetry exporter endpoint: an absolute http: or https: URL. A bare host:port such as localhost:4318 parses as a URL with the scheme localhost:, so the scheme is checked explicitly. An empty value is read as unset.

OTEL_SERVICE_NAME? ​

optional OTEL_SERVICE_NAME?: string

Optional OpenTelemetry service name. The core parser leaves it undefined when absent or empty (the OpenTelemetry SDK reads an empty value of an environment variable as unset); provider defaults belong to the telemetry package.

PORT ​

PORT: number

Server port: a whole number from 1 to 65535 written in decimal digits. A fraction, or a form Number() would read (0x50, 1e3, +80, padded with spaces), is rejected here instead of being read as another port or failing later inside the network layer.

Default ​

ts
5000

Example ​

typescript
const config = parseEnvConfig();
// or with custom env
const config = parseEnvConfig({ PORT: '8080' });