Skip to content

Configuration ​

Configuration is managed via BaseAppConfig, which uses @zyno-io/config to load values from environment variables. Extend it with your own properties.

typescript
import { BaseAppConfig } from '@zyno-io/dk-server-foundation';

class AppConfig extends BaseAppConfig {
    STRIPE_KEY_SECRET!: string;
    MAX_UPLOAD_SIZE: number = 10_000_000;
}

Properties ending in _SECRET are treated as secrets by the config loader.

Built-in Configuration ​

Application ​

VariableTypeDefaultDescription
APP_ENVstring—Application environment (development, production, etc.)
PORTnumber3000HTTP server port

Database Selection ​

VariableTypeDefaultDescription
DB_ADAPTER'mysql' | 'postgres'—Selects the database dialect when using createDatabase(sharedConfig) (see Database).

MySQL Database ​

VariableTypeDefaultDescription
MYSQL_HOSTstring—Database host
MYSQL_PORTnumber—Database port
MYSQL_USERstring—Database user
MYSQL_PASSWORD_SECRETstring—Database password
MYSQL_DATABASEstring—Database name
MYSQL_CONNECTION_LIMITnumber10 (prod) / 5 (dev)Max pool connections
MYSQL_MIN_IDLE_CONNECTIONSnumber— (prod) / 1 (dev)Minimum idle connections
MYSQL_IDLE_TIMEOUT_SECONDSnumber60 (prod) / 5 (dev)Idle connection timeout

JWT Authentication ​

VariableTypeDefaultDescription
AUTH_JWT_ISSUERstring—JWT issuer claim
AUTH_JWT_EXPIRATION_MINSnumber—Token expiration in minutes
AUTH_JWT_COOKIE_NAMEstring—Cookie name for JWT storage
AUTH_JWT_SECRETstring—HMAC secret (plain string)
AUTH_JWT_SECRET_B64string—HMAC secret (base64-encoded)
AUTH_JWT_ED_SECRETstring—EdDSA private key (PEM, base64-encoded)
AUTH_JWT_ENABLE_VERIFYbooleantrueEnable JWT signature verification

Basic Authentication ​

VariableTypeDefaultDescription
AUTH_BASIC_SECRETstring—Password for HTTP Basic Auth

Cryptography ​

VariableTypeDefaultDescription
CRYPTO_SECRETstring—32-byte key (or 64 hex chars) for AES-256-GCM
CRYPTO_IV_LENGTHnumber12IV length for AES-GCM

HTTP ​

VariableTypeDefaultDescription
USE_REAL_IP_HEADERboolean—Trust x-real-ip header from reverse proxy
HTTP_REQUEST_LOGGING_MODEstringe2eLogging mode: none, e2e, finish, errors
HEALTHZ_ENABLE_REQUEST_LOGGINGbooleanfalseLog healthcheck requests

Redis ​

All Redis configurations support both direct connection and Sentinel mode. The library uses separate Redis instances for different concerns:

Default Redis ​

VariableDescription
REDIS_HOSTRedis host
REDIS_PORTRedis port
REDIS_PREFIXKey prefix (falls back to package name)
REDIS_SENTINEL_HOSTSentinel host
REDIS_SENTINEL_PORTSentinel port
REDIS_SENTINEL_NAMESentinel master name

Cache Redis (CACHE_REDIS_ prefix) ​

Used by the Cache class. Falls back to default Redis settings.

Broadcast Redis (BROADCAST_REDIS_ prefix) ​

Used by createBroadcastChannel() and createDistributedMethod(). Falls back to default Redis settings.

BullMQ Redis (BULL_REDIS_ prefix) ​

Used by the worker system. Falls back to default Redis settings.

VariableTypeDefaultDescription
BULL_QUEUEstringdefaultDefault BullMQ queue name

Mesh Redis (MESH_REDIS_ prefix) ​

Used by MeshService. Falls back to default Redis settings.

Mutex Redis (MUTEX_REDIS_ prefix) ​

Used by withMutex() and LeaderService. Falls back to default Redis settings.

VariableTypeDefaultDescription
MUTEX_MODEstringlocalMutex mode: local (in-process) or redis

Mail ​

VariableTypeDefaultDescription
MAIL_PROVIDERstringsmtpMail provider: smtp or postmark
MAIL_FROMstring—Sender email address
MAIL_FROM_NAMEstring—Sender display name
SMTP_HOSTstring127.0.0.1SMTP server host
SMTP_PORTnumber1025SMTP server port
SMTP_USERstring—SMTP username
SMTP_PASSWORD_SECRETstring—SMTP password
SMTP_TLSbooleanfalseEnable TLS
POSTMARK_SECRETstring—Postmark API token

Workers ​

VariableTypeDefaultDescription
ENABLE_JOB_RUNNERbooleantrue (dev)Enable BullMQ job runner

Observability ​

VariableTypeDefaultDescription
SENTRY_DSNstring—Sentry DSN for error tracking
OTEL_EXPORTER_OTLP_ENDPOINTstring—OTLP endpoint for traces and metrics
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTstring—OTLP endpoint for traces only
OTEL_EXPORTER_OTLP_METRICS_ENDPOINTstring—OTLP endpoint for metrics push
OTEL_METRICS_ENDPOINT_ENABLEDboolean—Enable /metrics Prometheus endpoint
OTEL_DEBUGboolean—Enable debug logging
ALERTS_SLACK_WEBHOOK_URLstring—Slack webhook for alert-level errors

SRPC ​

VariableTypeDefaultDescription
SRPC_AUTH_SECRETstring—HMAC secret for SRPC authentication
SRPC_AUTH_CLOCK_DRIFT_MSnumber30000Allowed clock drift for SRPC auth

OpenAPI ​

VariableTypeDefaultDescription
ENABLE_OPENAPI_SCHEMAboolean—Dump OpenAPI schema to openapi.yaml

isDevFeatureEnabled(envVar, defaultInDev?) ​

Helper function to check if a feature flag is enabled. Returns true in development/Jest by default.

typescript
import { isDevFeatureEnabled } from '@zyno-io/dk-server-foundation';

if (isDevFeatureEnabled(config.MY_FEATURE)) {
    // enabled
}
InputProductionDevelopment
undefinedfalsetrue (default)
'1' or 'true'truetrue
'0' or 'false'falsefalse

Released under the MIT License.