A feature-complete HTTP server implementation for Omi written in JavaScript/TypeScript, compatible with Node.js, Bun, and Deno.
-
Authentication & Authorization
- User account management (sign-in, sign-up)
- TOTP/OTP 2FA support
- Brute force protection with account lockouts
- Session-based authentication
- API rate limiting
-
Repository Management
- SQLite-based file storage and versioning
- Repository browsing with directory navigation
- File upload and download
- Commit history and logging
-
File Operations
- Text file viewing and editing
- Markdown rendering
- SVG rendering with security checks
- Audio/video player support
- File deletion with confirmation
-
User Management
- Create/delete users
- Password management
- OTP enablement/disablement
- User directory listing
-
API Endpoints
- Repository list (JSON)
- Repository download
- Repository upload with authentication
- Rate limiting and error handling
- Node.js 14.0+ (with ES modules support)
- Built-in
fs,path,crypto,httpmodules
- Bun 1.0+ (optional, full compatibility with Node.js APIs)
- Deno 1.30+ with
--allow-net,--allow-read,--allow-writepermissions
cd /path/to/wekan/public
node server.jscd /path/to/wekan/public
bun server.jsdeno run --allow-net --allow-read --allow-write server.jsThe server reads from settings.txt in the parent directory (../settings.txt):
SQLITE=sqlite
USERNAME=admin
PASSWORD=password
REPOS=http://localhost:8080
CURL=curl
API_ENABLED=1
API_RATE_LIMIT=60
API_RATE_LIMIT_WINDOW=60
ACCOUNTS_LOCKOUT_KNOWN_USERS_FAILURES_BEFORE=3
ACCOUNTS_LOCKOUT_KNOWN_USERS_FAILURE_WINDOW=15
ACCOUNTS_LOCKOUT_KNOWN_USERS_PERIOD=60
ACCOUNTS_LOCKOUT_UNKNOWN_USERS_FAILURES_BEFORE=3
ACCOUNTS_LOCKOUT_UNKNOWN_USERS_FAILURE_WINDOW=15
ACCOUNTS_LOCKOUT_UNKNOWN_USERS_LOCKOUT_PERIOD=60
Users are stored in users.txt with format:
username:password:otpauth_url
user1:pass123:
user2:pass456:otpauth://totp/Omi(user2)?secret=JBSWY3DPEBLW64TMMQ==
The server implements configurable API rate limiting:
- Default: 60 requests per 60 seconds per user
- Configurable via
API_RATE_LIMITandAPI_RATE_LIMIT_WINDOWin settings.txt - Rate limit info returned in response headers:
X-RateLimit-LimitX-RateLimit-RemainingX-RateLimit-Reset
| Route | Method | Description |
|---|---|---|
/ |
GET | Repository list |
/sign-in |
GET/POST | User authentication |
/sign-up |
GET/POST | User registration |
/logout |
GET | End session |
/settings |
GET/POST | Server settings (auth required) |
/people |
GET/POST | User management (auth required) |
/{repo} |
GET | Browse repository |
/?format=json |
GET | List repos as JSON |
/?download={repo}.omi |
GET | Download repository |
All API requests require:
- POST data with
username,password, and optionalotp_code - Returns JSON responses with status and rate limit headers
- Path traversal protection via
isPathSafe()validation - SVG malicious code detection (JavaScript, XML entities)
- XSS prevention via HTML escaping
- Session-based authentication with secure cookies
- Brute force protection with configurable lockouts
- API rate limiting
- OTP support for 2FA
- Check that port 8080 is not in use
- Ensure proper file permissions for
repos/directory - Verify settings.txt and user files exist
- Clear cookies/sessions if locked out
- Check users.txt format:
username:password:otp - Verify OTP secret format in otpauth URL
- Check repository name ends with
.omi - Verify directory permissions
- Ensure sufficient disk space
- Most common runtime, best compatibility
- Requires
--experimental-modulesflag for older versions - Use
node server.jsto start
- Faster startup and execution
- Full Node.js API compatibility
- Use
bun server.jsto start
- Requires explicit permissions (--allow-net, --allow-read, --allow-write)
- Different module resolution (uses URLs and imports map)
- Use
deno run --allow-net --allow-read --allow-write server.jsto start
- README.md - Documentation index
- WEB.md - Web interface guide
- SERVER_FREEPASCAL.md - FreePascal server guide
- SERVER_PHP.md - PHP server guide
- DATABASE_SCHEMA.md - SQLite schema
- CLI_PYTHON3.md - Python CLI (similar architecture)
- CLI_C89.md - C89 CLI
- CLI_TCL.md - Tcl CLI
- Server uses in-memory session storage; consider database session storage for production
- Multipart form parsing is simplified; for large uploads, enhance the parser
- For production use, add HTTPS/TLS support via reverse proxy (nginx, Caddy)
- Monitor rate limiting effectiveness and adjust thresholds as needed