@cvo/core
v0.0.0
Published
Core package for CVO Framework
Readme
@cvo/core
The foundational library of the CVO Framework. It defines the core abstractions, decorators, and shared types used by both the server and the compiler.
🚀 Key Features
- Metadata Decorators: Provides the essential decorators for defining APIs (
@http,@Body,@Query,@Path,@Header). - Structured Error System: Defines the
BackendErrorclass, enabling a unified way to handle exceptions with i18n support and HTTP status codes. - Configuration Schema: Exports the
defineConfigutility and theCvoConfigtype for project-wide settings. - Type Utilities: A collection of TypeScript utilities for managing full-stack type safety.
🛠 Core Concepts
Decorators
Decorators are used to attach metadata to your functions and classes. This metadata is then used by @cvo/server at runtime and @cvo/compiler at build time.
import { http, Body } from '@cvo/core';
@http('POST', '/api/data')
export async function handleData(@Body data: MyDataDto) {
// ...
}BackendError
A specialized error class that ensures all backend failures are informative and translatable.
import { BackendError } from '@cvo/core';
throw new BackendError('user.not_found', 404, { userId: '123' });📦 Installation
pnpm add @cvo/core