@cvo/server
v0.0.0
Published
Server package for CVO Framework
Downloads
51
Readme
@cvo/server
The high-performance server runtime for the CVO Framework. It handles request routing, parameter extraction, and the execution lifecycle of your backend logic.
🚀 Key Features
- Automatic Routing: Dynamically registers HTTP routes based on the metadata attached to your API functions and classes.
- Advanced Parameter Extraction: Uses "Extractors" to automatically map request bodies, queries, headers, and path parameters directly to function arguments.
- Deep Prisma Integration: Built-in support for Prisma. Automatically initializes connection, handles transactions via
AsyncLocalStorage, and provides type-safectx.dbaccess without additional plugins. - Integrated i18n: Automatically detects the user's locale from headers and provides a translation function (
ctx.t) within the request context. - Plugin System: Easily extendable with official and third-party plugins for authentication, logging, real-time communication (WebSockets/SSE), and more.
🛠 Usage
import { MonoServer } from '@cvo/server';
import config from './cvo.config';
const server = new MonoServer(config);
server.listen(config.port, () => {
console.log(`CVO Server running on port ${config.port}`);
});🧠 Request Lifecycle
- Request Received: The raw HTTP request is captured.
- Context Creation: A
RequestContextis initialized, including i18n providers and state maps. - Middleware Execution: Global and route-specific middlewares are executed.
- Parameter Extraction: Extractors parse the request data into typed arguments.
- Handler Execution: Your business logic function is called with the extracted arguments.
- Response Handling: The function result is serialized to JSON and sent to the client. If a
BackendErroroccurs, it is automatically translated and returned with the appropriate HTTP status.
