Skip to content

Define Fetch application and request context contracts #3437

Description

@Romakita

Parent Epic: #3436

Goal

Define the public contracts that make a Ts.ED application a native Fetch application while keeping the HTTP core independent from Node.js and framework-specific abstractions.

Scope

  • Define the TsEDFetchApp / Fetch handler contract.
  • Define an optional runtime context for capabilities not represented by Request.
  • Revisit PlatformContext for a Fetch-native HTTP model.
  • Use standard Web primitives (Request, Response, URL, Headers, FormData, ReadableStream, AbortSignal).
  • Define request-scoped DI lifecycle around a Fetch request.
  • Ensure the public contract does not expose IncomingMessage, ServerResponse, Koa context, Express request/response, or equivalent wrappers.

Candidate API

interface TsEDFetchApp {
  fetch(request: Request, context?: RuntimeContext): Response | Promise<Response>;
}

interface RuntimeContext<Env = unknown, Platform = unknown> {
  env?: Env;
  platform?: Platform;
  waitUntil?(promise: Promise<unknown>): void;
}

The exact API is part of this story and may evolve during implementation.

Acceptance criteria

  • A stable Fetch handler contract is defined and exported by @tsed/platform-fetch.
  • Request-scoped Ts.ED context can be created from a standard Request.
  • Runtime-specific information can be supplied without mutating or wrapping Request.
  • No node:http types leak into the public Fetch contracts.
  • The contracts can represent Bun/Workers/Vike/Hono-style execution without framework-specific types.
  • Unit tests validate the contracts using Web API objects only.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions