Below is a detailed table describing each environment variable in the witches.env file:

Environment Variables Reference#

VariableDescriptionTypeDefault Value
SERVER CONFIGURATION
APP_PORTHTTP server portint8080
APP_HOSTServer binding hostnamestringlocalhost
METRIC_PORTPrometheus metrics portint8088
UID_BITSNumber of bits for ID generation (Snowflake/ULID)int26
REQUEST_KEYKey for storing request contextstringrequest_context
LOGGING
LOG_PATHDirectory for log filesstring./logs
CORS
CORS_ALLOW_ORIGINSAllowed origins (* = all)string*
CORS_ALLOW_METHODSAllowed HTTP methodsstringGET,POST,PUT,DELETE,OPTIONS
CORS_ALLOW_HEADERSAllowed request headersstringContent-Type,Authorization
TIMEZONE
TIMEZONEApplication timezonestringUTC
SUPPORTED_LANGUAGESSupported languages (for i18n)stringen-US,vi-VN
SECURITY
JWT_SECRETSecret key for JWT signingstringyour_secret_key
DATABASE CONFIGURATION
DB_DRIVERDatabase driver (postgres/mysql/mssql)stringyour_driver
DB_USERDatabase usernamestringyour_user
DB_HOSTDatabase hoststringlocalhost
DB_PORTDatabase portint3306
DB_NAMEDatabase namestringyour_database
DB_PASSWORDDatabase passwordstringyour_password
Database Connection Pool
DB_MAX_OPEN_CONNSMaximum number of open connectionsint100
DB_MAX_IDLE_CONNSMaximum number of idle connectionsint10
DB_CONN_MAX_LIFETIMEMaximum lifetime of a connection (seconds)int60
DB_CONN_MAX_IDLE_TIMEMaximum idle time of a connection (seconds)int600
SLOW_THRESHOLDThreshold for slow query logging (seconds)float5
REDIS CONFIGURATION
REDIS_HOSTRedis server hoststringlocalhost
REDIS_PORTRedis server portint6379
REDIS_PASSWORDRedis password (leave empty if none)stringempty
TOKEN EXPIRATION
ACCESS_TOKEN_TTLAccess token lifetime (seconds)int900 (15 minutes)
REFRESH_TOKEN_TTLRefresh token lifetime (seconds)int604800 (7 days)
SESSION SETTINGS
SESSION_TTLSession lifetime (seconds)int604800 (7 days)
IDLE_TIMEOUTSession idle timeout (seconds)int1800 (30 minutes)
BLACKLIST SETTINGS
REVOKED_TTLRevoked token storage time (seconds)int300 (5 minutes)
RATE LIMIT
RATE_LIMIT_PERIODRate limit period (seconds)int60
RATE_LIMIT_MAXMaximum requests per periodint100

Notes#

  • Time values: All TTL/time values are in seconds.
  • DB_DRIVER: Valid values: postgres, postgresql, mysql, mssql, sqlserver.
  • CORS_ALLOW_ORIGINS: Use * for all origins, or comma-separate multiple origins.
  • JWT_SECRET: Should be changed to a strong secret key in production environments.