Skip to content

Server Options

MikroChat can be started directly with Node.js from the API release archive. All configuration can be provided via CLI flags, environment variables, or a configuration file.

Terminal window
node lib/mikrochat.mjs
# With options
node lib/mikrochat.mjs --port 3001 --debug
FlagDescriptionDefault
--portPort to listen on3000
--hostHost/bind address127.0.0.1
--httpsEnable HTTPSfalse
--http2Enable HTTP/2false
--certSSL certificate path-
--keySSL private key path-
--caSSL CA certificate path-
--ratelimitEnable rate limitingtrue
--rpsRequests per minute limit100
--allowedComma-separated allowed domains-
--debugEnable debug modefalse
FlagDescriptionDefault
--jwtSecretJWT signing key-
--appUrlBase URL for magic links-
--magicLinkExpirySecondsMagic link expiry time900
--jwtExpirySecondsJWT expiry time900
--refreshTokenExpirySecondsRefresh token expiry604800
--maxActiveSessionsMax sessions per user3
--authModeAuth modemagic-link
--isInviteRequiredRequire admin invitetrue
FlagDescriptionDefault
--initialUserIdInitial admin user ID-
--initialUserNameInitial admin username-
--initialUserEmailInitial admin email-
--initialUserPasswordInitial admin password-
--messageRetentionDaysDays to keep messages30
--maxMessagesPerChannelMax messages per channel100
FlagDescriptionDefault
--emailSubjectMagic link email subjectYour Secure Login Link
--emailHostSMTP host-
--emailUserSMTP username-
--emailPasswordSMTP password-
--emailPortSMTP port465
--emailSecureUse secure connectiontrue
--emailMaxRetriesMax delivery attempts2
FlagDescriptionDefault
--dbDatabase directory pathmikrochat_db
--encryptionKeyEncryption key for data at rest-
VariableDescription
MIKROCHAT_PORTServer port
PORTServer port fallback
HOSTServer host
DEBUGEnable debug mode
AUTH_JWT_SECRETJWT signing key
APP_URLBase URL for magic links
INITIAL_USER_IDInitial admin user ID
INITIAL_USER_NAMEInitial admin username
INITIAL_USER_EMAILInitial admin email
INITIAL_USER_PASSWORDInitial admin password
EMAIL_USERSMTP username
EMAIL_HOSTSMTP host
EMAIL_PASSWORDSMTP password
STORAGE_KEYEncryption key

Create mikrochat.config.json in the working directory:

{
"auth": {
"jwtSecret": "your-secret-key",
"authMode": "magic-link",
"appUrl": "https://chat.example.com",
"isInviteRequired": true
},
"chat": {
"initialUser": {
"userName": "admin",
"email": "[email protected]",
"password": ""
}
},
"server": {
"port": 3000
}
}

See Configuration for the complete reference.

Settings are applied in this order (highest priority first):

  1. CLI flags
  2. Configuration file (mikrochat.config.json)
  3. Default values (which include environment variables)
Terminal window
# Custom port
node lib/mikrochat.mjs --port 3001 --debug
Terminal window
# With environment variables
MIKROCHAT_PORT=3000 \
AUTH_JWT_SECRET=your-secret \
EMAIL_HOST=smtp.example.com \
EMAIL_PASSWORD=password \
node lib/mikrochat.mjs
# With HTTPS
node lib/mikrochat.mjs \
--https \
--cert /path/to/cert.pem \
--key /path/to/key.pem
# With rate limiting
node lib/mikrochat.mjs --ratelimit --rps 60
Terminal window
docker run -d \
-e MIKROCHAT_PORT=3000 \
-e AUTH_JWT_SECRET=your-secret \
-v mikrochat-data:/app/mikrochat_db \
-p 3000:3000 \
mikrochat

Enable debug mode to see verbose logs:

Terminal window
# Via CLI flag
node lib/mikrochat.mjs --debug
# Via environment variable
DEBUG=true node lib/mikrochat.mjs

Debug mode logs:

  • Incoming HTTP requests
  • Authentication events
  • Database operations
  • SSE connection lifecycle
  • Email delivery attempts

The server exposes a health endpoint:

Terminal window
curl http://127.0.0.1:3000/health
# Returns: OK

Use this for container health checks and load balancer probes.