CLI and Server Options
MikroChat CLI
Section titled “MikroChat CLI”The mikrochat CLI is installed via the curl oneliner and provides commands for managing your MikroChat installation.
curl -sSL https://releases.mikrochat.com/install.sh | bashCommands
Section titled “Commands”| Command | Description |
|---|---|
mikrochat install | Download and install MikroChat to ~/.mikrochat/ |
mikrochat init | Create config and copy web app to current directory |
mikrochat start | Start the MikroChat API server |
mikrochat upgrade | Check for updates and upgrade to the latest version |
mikrochat version | Show the installed version |
mikrochat uninstall | Remove MikroChat from your system |
mikrochat docs | Open the documentation in your browser |
How It Works
Section titled “How It Works”~/.mikrochat/stores the installed API and web app files~/.local/bin/mikrochatis the CLI wrapper scriptmikrochat startruns the API from your current working directory, somikrochat.config.jsonandmikrochat_db/live in your project foldermikrochat initcopies the web app files to./app/in your current directory for easy web server setup
Passing Flags
Section titled “Passing Flags”Any flags after mikrochat start are forwarded to the Node.js server:
mikrochat start --port 4000 --debugServer Options
Section titled “Server Options”MikroChat can also be started directly with Node.js. All configuration can be provided via CLI flags, environment variables, or a configuration file.
# Using the CLImikrochat start
# Using Node.js directlynode mikrochat.mjs
# With optionsnode mikrochat.mjs --port 3001 --debugServer Flags
Section titled “Server Flags”| Flag | Description | Default |
|---|---|---|
--port | Port to listen on | 3000 |
--host | Host/bind address | localhost |
--https | Enable HTTPS | false |
--http2 | Enable HTTP/2 | false |
--cert | SSL certificate path | - |
--key | SSL private key path | - |
--ca | SSL CA certificate path | - |
--ratelimit | Enable rate limiting | true |
--rps | Requests per minute limit | 100 |
--allowed | Comma-separated allowed domains | - |
--debug | Enable debug mode | false |
Authentication Flags
Section titled “Authentication Flags”| Flag | Description | Default |
|---|---|---|
--jwtSecret | JWT signing key | - |
--appUrl | Base URL for magic links | - |
--magicLinkExpirySeconds | Magic link expiry time | 900 |
--jwtExpirySeconds | JWT expiry time | 900 |
--refreshTokenExpirySeconds | Refresh token expiry | 604800 |
--maxActiveSessions | Max sessions per user | 3 |
--authMode | Auth mode | magic-link |
--isInviteRequired | Require admin invite | true |
Chat Flags
Section titled “Chat Flags”| Flag | Description | Default |
|---|---|---|
--initialUserId | Initial admin user ID | - |
--initialUserName | Initial admin username | - |
--initialUserEmail | Initial admin email | - |
--initialUserPassword | Initial admin password | - |
--messageRetentionDays | Days to keep messages | 30 |
--maxMessagesPerChannel | Max messages per channel | 100 |
Email Flags
Section titled “Email Flags”| Flag | Description | Default |
|---|---|---|
--emailSubject | Magic link email subject | Your Secure Login Link |
--emailHost | SMTP host | - |
--emailUser | SMTP username | - |
--emailPassword | SMTP password | - |
--emailPort | SMTP port | 465 |
--emailSecure | Use secure connection | true |
--emailMaxRetries | Max delivery attempts | 2 |
Storage Flags
Section titled “Storage Flags”| Flag | Description | Default |
|---|---|---|
--db | Database directory path | mikrochat_db |
--encryptionKey | Encryption key for data at rest | - |
Environment Variables
Section titled “Environment Variables”| Variable | Description |
|---|---|
PORT | Server port |
HOST | Server host |
DEBUG | Enable debug mode |
AUTH_JWT_SECRET | JWT signing key |
APP_URL | Base URL for magic links |
INITIAL_USER_ID | Initial admin user ID |
INITIAL_USER_NAME | Initial admin username |
INITIAL_USER_EMAIL | Initial admin email |
INITIAL_USER_PASSWORD | Initial admin password |
EMAIL_USER | SMTP username |
EMAIL_HOST | SMTP host |
EMAIL_PASSWORD | SMTP password |
STORAGE_KEY | Encryption key |
Configuration File
Section titled “Configuration File”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": "admin@example.com", "password": "" } }, "server": { "port": 3000 }}See Configuration for the complete reference.
Configuration Priority
Section titled “Configuration Priority”Settings are applied in this order (highest priority first):
- CLI flags
- Configuration file (
mikrochat.config.json) - Default values (which include environment variables)
Examples
Section titled “Examples”Development
Section titled “Development”# Start with dev mode (from source)npm start
# Custom portmikrochat start --port 3001 --debugProduction
Section titled “Production”# With environment variablesPORT=3000 \AUTH_JWT_SECRET=your-secret \EMAIL_HOST=smtp.example.com \EMAIL_USER=noreply@example.com \EMAIL_PASSWORD=password \mikrochat start
# With HTTPSmikrochat start \ --https \ --cert /path/to/cert.pem \ --key /path/to/key.pem
# With rate limitingmikrochat start --ratelimit --rps 60Docker
Section titled “Docker”docker run -d \ -e PORT=3000 \ -e AUTH_JWT_SECRET=your-secret \ -v mikrochat-data:/app/mikrochat_db \ -p 3000:3000 \ mikrochatDevelopment Scripts
Section titled “Development Scripts”When working with the source code:
| Script | Description |
|---|---|
npm run dev | Start frontend file server (port 8000) |
npm run dev:reload | Build frontend + start backend (port 3000) |
npm start | Start the backend server |
npm run build | Build everything for production |
npm run build:web | Build frontend only |
npm run build:api | Build backend only |
npm test | Run tests |
npm run lint | Run linter |
Debugging
Section titled “Debugging”Enable debug mode to see verbose logs:
# Via CLI flagmikrochat start --debug
# Via environment variableDEBUG=true mikrochat startDebug mode logs:
- Incoming HTTP requests
- Authentication events
- Database operations
- SSE connection lifecycle
- Email delivery attempts
Health Check
Section titled “Health Check”The server exposes a health endpoint:
curl http://localhost:3000/health# Returns: OKUse this for container health checks and load balancer probes.