Deepkit

repository·master·Indexed 25 days ago

https://github.com/marcj/deepkit

A TypeScript framework that preserves types at runtime via a compiler plugin, enabling a single type definition for validation, serialization, database schemas, HTTP routing, and dependency injection. It includes packages for Angular SSR, BSON parsing with JIT optimization, Bun runtime integration, and a CLI framework via @deepkit/app.

Tokens
123.4K
Snippets
408
Records
661
Agent score
86%

What's inside Deepkit

  1. Overview of @deepkit/injector

    master
    @deepkit/injector is a high-performance, compiling dependency injection (DI) container for the Deepkit Framework. It supports constructor and property injection, type-safe configuration, and automatic dependency inference using reflect-metadata and emitDecoratorMetadata. It also features compiler passes to modify provider construction, various provider types (Factory, Value, Class, Existing), scoped dependencies (e.g., 'request' scopes), and tagged providers.
  2. Overview of @deepkit/http features

    master

    The @deepkit/http package provides a high-performance HTTP router with the following capabilities:

    • Runtime Types: Define RPC functions using standard TypeScript types.
    • Validation: Built-in parameter validation derived directly from TypeScript types.
    • Dependency Injection: Full dependency injection support for both classes and functions.
    • Event System: A powerful system to hook into the HTTP request lifecycle.
    • Middleware: Support for registering global middleware or route-specific middleware.
    • JSX Views: Performant view rendering using JSX.
  3. Overview of Deepkit features and capabilities

    master
    Deepkit is a TypeScript-centric framework designed to bridge the gap between compile-time type safety and runtime functionality. Unlike standard TypeScript which erases type information during compilation, Deepkit retains and enables the use of type information at runtime. This allows for advanced features like dynamic type computation, automated data validation, and seamless serialization without the need for cumbersome workarounds like manual code generation or complex type builders (e.g., Zod).
  4. Overview of Deepkit Dependency Injection

    master
    Deepkit Dependency Injection (@deepkit/injector) is a high-performance dependency injection container for TypeScript. It is built on top of Deepkit's runtime types, allowing for zero-boilerplate injection without the need for decorators. It supports constructor, property, and method injection, as well as dependency inversion (depending on interfaces), scoped sub-containers (for HTTP, RPC, or custom scopes), and a module system with inheritance and encapsulated containers.
  5. Overview of Deepkit ORM

    master

    Deepkit ORM is a high-performance TypeScript Object-Relational Mapper (ORM) designed for interacting with databases using an intuitive, object-oriented API. It is built on top of Deepkit's Runtime Type System, which enables a typesafe environment for database operations.

    Key benefits include:

    • Simplified Operations: Abstracting manual SQL queries into object-oriented methods for querying, inserting, updating, and deleting records.
    • Cross-Database Compatibility: Provides a consistent, database-agnostic API, allowing for easier switching between engines like MySQL, PostgreSQL, or SQLite.
    • Type Safety: Uses TypeScript classes or interfaces to define schemas, enabling compile-time error detection and automatic type conversion/validation via the runtime type system.
  6. Understand the Deepkit CLI architecture

    master

    In Deepkit, there is no global CLI tool. Instead, your application is launched via a TypeScript file that acts as a CLI program. This program has full access to the Dependency Injection (DI) container, allowing it to access all providers and configuration options.

    CLI is one of the three primary entry points to a Deepkit application. You use this same entry point to launch HTTP/RPC servers, perform migrations, or run custom commands. Once you import FrameworkModule from @deepkit/framework, the application automatically gains additional commands for the application server and migrations.

  7. Use @deepkit/template for JSX-based HTML/XML generation

    master

    Deepkit Template is a JSX-based template engine used to generate HTML or XML formats. It allows you to write XML-based structures in a type-safe way using JSX, which is a superset of JavaScript. Components can be standard functions or asynchronous functions.

    export function MyComponent(props: { title: string }) {
        return <div>Hello {props.title}</div>;
    }
    
    router.get('/hello/:text', (text: string) => {
        return <MyComponent title={text}/>;
    });
    
    // GET /hello/world => <div>Hello world</div>