Ts.ED Framework Documentation

repository·production·Indexed 25 days ago

https://github.com/tsedio/tsed

A TypeScript framework built on top of Express, featuring a powerful Dependency Injection toolkit (@tsed/di) and a flexible configuration system (@tsed/config). It supports multiple configuration sources including environment variables, JSON, YAML, DotEnv, and external services such as AWS Secrets Manager, Redis, MongoDB, HashiCorp Vault, and Postgres, with support for real-time watch mode and schema validation.

Tokens
227.7K
Snippets
651
Records
1.1K
Agent score
83%

What's inside Ts.ED

  1. Overview of Ts.ED

    production

    Ts.ED is a framework designed for building scalable server-side applications in a Node.js environment. It is built with TypeScript and supports multiple programming paradigms, including Object-Oriented Programming (OOP) using classes and decorators, as well as Functional programming.

    Ts.ED provides an abstraction layer over common Node.js HTTP frameworks via its Platform API, while still allowing direct access to the underlying framework's APIs for maximum flexibility.

  2. Overview of @tsed/platform-mcp

    production

    The @tsed/platform-mcp package allows any Ts.ED HTTP adapter (such as Express, Fastify, or Koa) to expose an MCP endpoint. It enables the registration of MCP tools, resources, and prompts using either decorators or functional helpers.

    Key features include:

    • PlatformMcpModule: Mounts a configurable /mcp endpoint on top of @tsed/platform-http.
    • Functional helpers: defineTool, defineResource, and definePrompt for registering handlers via DI tokens.
    • Decorators: @Tool, @Prompt, and @Resource for declarative registration within services or controllers.
    • Shared utilities: Includes MCP_SERVER and transport helpers to integrate the MCP SDK v2 server packages into the Ts.ED dependency injection system.
  3. Overview of Ts.ED Framework

    production
    Ts.ED is a modern TypeScript framework designed for Node.js and Bun.js runtimes. It is built on top of popular web frameworks like Express.js, Koa.js, or Fastify.js and focuses on improving developer experience through a class-based architecture using decorators. It supports various deployment models, including standard server environments and serverless architectures (e.g., AWS).
  4. Overview of Ts.ED Engines

    production

    Ts.ED Engines is a template engine consolidation library that allows you to support multiple engine libraries within a single application.

    Key features include:

    • Support for multiple engine libraries.
    • Extensibility: You can register your own custom engines.
    • Configurable settings.
    • Framework agnostic: Works with both Express and Koa (and is explicitly compatible with Express).
  5. Register providers in @tsed/di

    production

    Ts.ED supports several ways to register providers for Dependency Injection:

    • Class-based (Decorators): Use @Injectable for basic class providers, @Service for semantic clarity, or @Interceptor for registering interceptors.
    • Functional API (Decorator-less): Use injectable(), .factory(), .asyncFactory(), or .value() for manual or advanced registration.
    • Constants & Values: Use @Constant()/constant() for constants and @Value()/refValue() for injecting specific values.
    • Scopes: Providers can be registered with singleton, request, or custom scopes.
  6. Configure supported configuration sources

    production

    Ts.ED allows you to load configuration from various sources including environment variables, files, and databases. You can define a schema to validate values at runtime and enable watch mode to automatically reload configuration when changes are detected (excluding certain options like port).

    Standard Sources

    TypeWatch modeImportDescription
    EnvsNo@tsed/config/envsLoad from process.env
    DotEnvYes@tsed/config/dotenvLoad from .env files (supports dotenv-flow and dotenv-expand)
    JsonYes@tsed/config/jsonLoad from a JSON file
    YAMLYes@tsed/config/yamlLoad from a YAML file

    Premium Sources

    TypeWatch modeImportDescription
    AWS Secrets ManagerYes (polling)@tsedio/config-source-aws-secretsLoad from AWS Secrets Manager
    IORedisYes@tsedio/config-ioredisLoad from Redis via ioredis
    MongoYes@tsed/config-mongoLoad from a MongoDB collection
    VaultYes (polling)@tsed/config-vaultLoad from HashiCorp Vault
    PostgresYes@tsed/config-postgresLoad from a Postgres database
  7. Core Features of Ts.ED

    production

    Ts.ED provides several key capabilities for building robust applications:

    • Multi-platform Support: Build servers using Express.js, Koa.js, or Fastify.js on Node.js or Bun.js.
    • Class-based & Decorators: Define application components such as Controllers, ConfigSources, Models, Providers (DI), Interceptors, and Pipes using decorators.
    • CLI: Use the Ts.ED CLI to quickly scaffold preconfigured applications.
    • Plugin System: Extend functionality with over 100 available plugins or create your own.
    • AI-forward: Includes resources and templates (like AGENTS.md) to accelerate development with AI agents.
    • Testing: Built-in support for testing tools to ensure code quality.
  8. Use @tsed/json-mapper for serialization and deserialization

    production

    The @tsed/json-mapper package provides two primary functions to transform data between plain JavaScript objects and class models:

    • deserialize: Maps a plain object to a model instance.
    • serialize: Maps a model instance to a plain JavaScript object.

    This package relies on TypeScript metadata and decorators from the @tsed/schema package to perform these transformations. Ts.ED uses this internally to convert incoming request parameters into class instances and to convert endpoint return values into plain objects for the consumer.

  9. Features of @tsed/objection

    production

    The @tsed/objection package provides the following capabilities:

    • Single Connection Configuration: Configure one database connection using the @Configuration decorator.
    • Automatic Initialization: Databases are initialized during the server's OnInit phase.
    • Model Declaration: Declare models from classes using annotations. Note that @tsed/objection utilizes JsonSchema and its decorators to generate database tables.