Skip to main content
Version: v9.0.0

ElysiaAppToHyperFetch

Converts the type of an Elysia app into a Hyper Fetch SDK schema for createSdk .

Every route becomes a Request . The response is the union of the bodies the handler returns with a 2xx status, the local error is the union of the bodies of every other status, and the payload and query params come from the route's body and query schemas. Path segments become nested properties, :param segments become $param properties, and kebab-case segments become camelCase.

Response and error types follow what arrives over HTTP: dates become strings, null becomes the empty body "" , and streams, generators, Response objects and form() bodies are unknown . A body with file fields is typed as FormData .

Routes below an optional :param? segment appear both without and with the param. WebSocket routes, .all() routes, wildcard * segments, mounted handlers and paths with ten or more segments are left out. Anything that is not an Elysia app resolves to {} .


Import
import { ElysiaAppToHyperFetch } from "@hyper-fetch/elysia"

Preview​

type ElysiaAppToHyperFetch<App,Client> = App extends { ~Routes: infer Routes } ? ConvertNode<Routes, , Client> : {};