$ show metarhia/impress
Impress is an enterprise application server for Node.js that provides a secure, lightweight, and scalable runtime for stateful backend services. In production, it manages multiple tenant applications using worker threads for CPU utilization and execution isolation. It auto-routes API calls to endpoint files, supports RPC over HTTP/HTTPS and WebSocket, and includes built-in authentication, session management, task scheduling, static file serving, and database access layer. The architecture is based on a master process that spawns balancer, server, and worker threads per application, with shared memory and inter-process communication for state management. Key entry points include the impress.js master process, which loads applications from .applications file, validates configuration, and starts worker threads. Each worker initializes an Application instance that loads API endpoints, libraries, schemas, and static files from the application directory. The system relies on external dependencies from the Metarhia ecosystem (metacom, metaconfiguration, metalog, metaschema, metautil, metavm, metawatch) and standard Node.js modules. It does not use third-party npm packages for core functionality. Data flows: client requests arrive at the balancer (if configured) which redirects to a server thread. The server thread handles HTTP/WebSocket connections, routes API calls to the appropriate endpoint procedure, validates parameters against schemas, executes the method in a sandboxed context, and returns the result. Static files are served from memory cache with optional compression. Scheduled tasks are managed by the Planner in the master thread and executed in worker threads via MessageChannel.
The LLM identified 3 files worth highlighting for reuse:
Implements a simple HTTP load balancer that redirects requests to a random backend port. Uses 302/307 redirects, CORS headers, and retry logic for port binding. Self-contained with only standard Node.js and metautil/metacom dependencies.
Manages scheduled tasks with JSON file persistence, semaphore-based concurrency control, and cross-worker invocation via MessageChannel. Supports add/remove/stop operations and automatic restoration on startup. Could be extracted as a standalone scheduler library.
Defines a reusable RPC method wrapper with parameter/return schema validation, configurable timeout, semaphore-based queue, and error handling. Used by the API layer to wrap endpoint functions. Demonstrates clean separation of concerns for method definition.