# elysiajs/elysia — codebase unpack

> Canonical page: https://codevetter.com/unpack/elysia

This is a deterministic Repo Unpack scan of elysiajs/elysia — a structural map, not a review, security audit, or maintainer-endorsed description.

- Scanned commit: e037eca710e7ad193be09cc6615ab0dbe54af914 (2026-08-26)
- Last upstream commit: :broom: chore: correct spelling mistake in changelog
- Generated by codevetter 1.15.0 on 2026-10-02
- 270 files scanned · 1.9 MB

Source inspection; upstream code and tests were not executed.

## Languages

- TypeScript: 237 files
- JSON: 8 files
- Markdown: 7 files
- YAML: 7 files
- JavaScript: 2 files
- HTML: 1 files

## Repository structure

- test/ — 160 files
- example/ — 45 files
- src/ — 39 files
- .github/ — 8 files

Probable source entrypoint: `src/index.ts` (inferred from the tree, not upstream docs)

## Source layout — src/

- src/adapter/ — 10 files
- src/type-system/ — 4 files
- src/universal/ — 7 files
- src/ws/ — 3 files
- src/compose.ts — 1 file
- src/context.ts — 1 file
- src/cookies.ts — 1 file
- src/dynamic-handle.ts — 1 file
- src/error.ts — 1 file
- src/formats.ts — 1 file
- src/index.ts — 1 file
- src/manifest.ts — 1 file
- src/parse-query.ts — 1 file
- src/replace-schema.ts — 1 file

## Package

- package.json: elysia v1.4.30 — 25 declared dependencies

## Structural health signals

Average score 8.3/10 across 96 files; 4 hotspots. These are deterministic review leads, not proof of a bug.

## Recent history

- e037eca710e7 (2026-08-26) :broom: chore: correct spelling mistake in changelog
- acea3a76f0f7 (2026-08-26) :broom: chore: add SECURITY.md
- a6b9fc71824a (2026-08-26) :broom: chore: update for bun 1.4
- b1c325f35419 (2026-08-26) Merge branch 'main' of https://github.com/elysiajs/elysia
- b8256ccf6a06 (2026-08-26) :broom: chore: update for bun 1.4

## Overview

Elysia is a TypeScript HTTP and WebSocket framework for developers building typed server APIs, distributed here as the elysia npm package at version 1.4.30. Its central Elysia class combines fluent route registration, runtime schemas, lifecycle hooks and plugins with generated request handlers and a separate dynamic execution path. Bun supplies native serving and WebSockets, while Web Standard and experimental Cloudflare adapters expose alternative runtime boundaries.

## System map

The public Elysia class owns application configuration, routes, schemas, hooks and shared state. Execution divides between generated AOT handlers and a dynamic handler, with adapters supplying serving and response behavior. Storage in the inspected framework core consists of application memory and HTTP cookies. Packaging and CI target multiple module formats and runtime integrations.
- Elysia's generic parameters track base paths, singleton context, definitions, metadata, routes and scoped/local additions; runtime fields hold corresponding stores and registries. — [src/index.ts#L190-265](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L190-L265)
- The constructor defaults AOT from ELYSIA_AOT, enables normalization, schema encoding and native static responses, and selects BunAdapter when Bun exists unless an adapter is supplied. — [src/index.ts#L377-407](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L377-L407) [src/universal/env.ts#L1-7](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/universal/env.ts#L1-L7)
- Routing separates static path tables, native response tables, route history and lazy Memoirist HTTP/dynamic routers; parameter decoding uses fastDecodeURIComponent. — [src/index.ts#L303-335](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L303-L335) [src/index.ts#L1011-1053](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L1011-L1053)
- The fetch getter installs either composeGeneralHandler or createDynamicHandler; compile also invokes adapter.beforeCompile, while listen delegates to the adapter. — [src/index.ts#L8061-8110](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L8061-L8110) [src/index.ts#L8161-8167](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L8161-L8167)
- BunAdapter owns Bun.serve and WebSocket integration; WebStandardAdapter rejects listen, and CloudflareAdapter extends it with eager route and error-handler compilation. — [src/adapter/bun/index.ts#L349-396](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/index.ts#L349-L396) [src/adapter/web-standard/index.ts#L231-237](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/index.ts#L231-L237) [src/adapter/cloudflare-worker/index.ts#L23-56](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/cloudflare-worker/index.ts#L23-L56)
- Validation integrates TypeBox and Standard Schema; normalization can use exact-mirror with a cleaner fallback, and the manifest declares cookie, URI decoding and Memoirist dependencies. — [src/schema.ts#L535-588](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/schema.ts#L535-L588) [package.json#L191-224](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/package.json#L191-L224)
- Application state resides in singleton.store; request contexts reference that object, while cookie changes become HTTP headers rather than framework database writes in this inspected path. — [src/index.ts#L241-249](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L241-L249) [src/adapter/web-standard/index.ts#L169-183](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/index.ts#L169-L183) [src/adapter/utils.ts#L437-451](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/utils.ts#L437-L451)
- build.ts emits unbundled ESM/CJS files targeting Node 20 and generates declarations; package exports expose both formats, CI builds and tests, and release-published events trigger npm provenance publishing. — [build.ts#L10-29](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/build.ts#L10-L29) [package.json#L10-24](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/package.json#L10-L24) [.github/workflows/ci.yml#L21-35](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/.github/workflows/ci.yml#L21-L35) [.github/workflows/publish.yml#L37-51](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/.github/workflows/publish.yml#L37-L51)

## Feature catalog

The developer-facing surface centers on typed routing, validation and lifecycle control. Applications can share context and state, manage cookies, compose plugins and mount other fetch handlers. Response facilities cover ordinary values, files, streams and SSE, with Bun-specific WebSockets. These are framework APIs demonstrated by tests and examples, rather than product screens or application-specific endpoints.
- get and post register method-specific routes; route uppercases arbitrary method names, and add applies prefixes and distinguishes literal paths from parameter/wildcard paths. — [src/index.ts#L5798-5805](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L5798-L5805) [src/index.ts#L5908-5914](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L5908-L5914) [src/index.ts#L6772-6779](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L6772-L6779) [src/index.ts#L1011-1053](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L1011-L1053)
- Route schemas cover body, headers, params, query, cookie and status-dependent responses; Standard Schema tests demonstrate Zod validation and numeric query coercion. — [src/index.ts#L550-559](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L550-L559) [test/standard-schema/validate.test.ts#L7-46](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/standard-schema/validate.test.ts#L7-L46) [test/standard-schema/validate.test.ts#L131-181](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/standard-schema/validate.test.ts#L131-L181)
- Built-in body parsing supports JSON, text, URL encoding, ArrayBuffer and multipart forms; multipart parsing groups repeated values and reconstructs dotted/indexed nested fields. — [src/adapter/web-standard/index.ts#L27-62](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/index.ts#L27-L62) [src/adapter/web-standard/index.ts#L90-125](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/index.ts#L90-L125)
- Lifecycle hooks can transform context before validation, derive or resolve request properties, and intercept handling; tracing exposes request through error stages with timing and completion listeners. — [src/dynamic-handle.ts#L549-565](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L549-L565) [src/dynamic-handle.ts#L692-733](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L692-L733) [src/trace.ts#L6-38](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/trace.ts#L6-L38) [src/trace.ts#L50-77](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/trace.ts#L50-L77)
- state supports named values, object merges and store-mapping functions; decorate adds reusable context members, and the counter example mutates shared state on GET /. — [src/index.ts#L7102-7140](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L7102-L7140) [src/index.ts#L7270-7277](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L7270-L7277) [example/counter.ts#L1-6](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/example/counter.ts#L1-L6)
- Cookie objects expose values and attributes plus update, set and remove operations; parsing supports selected or all signed cookies and verification against rotated signing keys. — [src/cookies.ts#L308-345](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/cookies.ts#L308-L345) [src/cookies.ts#L373-432](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/cookies.ts#L373-L432) [test/cookie/signature.test.ts#L120-135](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/cookie/signature.test.ts#L120-L135)
- Bun WebSocket routes support connection callbacks, parsed/validated messages and response validation; ElysiaWS exposes send, subscription and publish facilities. — [src/adapter/bun/index.ts#L451-477](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/index.ts#L451-L477) [src/adapter/bun/index.ts#L589-627](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/index.ts#L589-L627) [src/ws/index.ts#L61-118](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/ws/index.ts#L61-L118)
- Response mapping handles JSON objects, strings, custom statuses, Response, files and streams; shared helpers implement byte ranges and SSE formatting, while use/group/guard/mount compose application behavior. — [src/adapter/web-standard/handler.ts#L52-155](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/handler.ts#L52-L155) [src/adapter/utils.ts#L19-80](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/utils.ts#L19-L80) [src/adapter/utils.ts#L271-305](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/utils.ts#L271-L305) [src/index.ts#L5585-5638](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L5585-L5638)

## Data flow

Registration converts developer declarations into route records and execution machinery before requests arrive. Requests enter through Fetch-compatible Request objects and acquire per-request context alongside shared application state. Parsing and schema providers transform boundary values before application handlers run. Responses cross adapter mapping, cookie serialization, streaming or WebSocket output boundaries.
- add expands macros, normalizes/prefixes paths and selects route schemas over inherited candidates before constructing route validators and compiled handlers. — [src/index.ts#L482-522](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L482-L522) [src/index.ts#L550-570](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L550-L570) [src/index.ts#L918-939](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L918-L939)
- WebStandard createContext extracts URL path/query positions, shares store and decorator values, and allocates request-local set headers/status. — [src/adapter/web-standard/index.ts#L147-190](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/index.ts#L147-L190)
- Dynamic dispatch runs application request hooks first, then searches method, WebSocket method and ALL routes; missing routes receive parsed query context before NotFoundError. — [src/dynamic-handle.ts#L247-278](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L247-L278)
- Dynamic body parsing skips GET/HEAD, then places parsed body, matched params, query values and header entries into context; parseQuery preserves repeated keys as arrays. — [src/dynamic-handle.ts#L285-303](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L285-L303) [src/dynamic-handle.ts#L473-482](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L473-L482) [src/parse-query.ts#L295-323](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/parse-query.ts#L295-L323)
- Standard Schema Validate propagates value/issues results and awaits Promise results; dynamic HTTP validation replaces context fields with validated output or throws ValidationError. — [src/schema.ts#L590-630](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/schema.ts#L590-L630) [src/dynamic-handle.ts#L189-205](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L189-L205) [src/dynamic-handle.ts#L672-688](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L672-L688)
- Parsed cookies become a proxy of Cookie objects backed by request-local set.cookie; outgoing properties are serialized and handleSet installs one or multiple Set-Cookie headers. — [src/cookies.ts#L348-370](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/cookies.ts#L348-L370) [src/cookies.ts#L456-479](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/cookies.ts#L456-L479) [src/adapter/utils.ts#L437-451](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/utils.ts#L437-L451)
- Web Standard mapResponse turns arrays/objects into JSON and dispatches files, custom statuses, promises and streams to specialized handlers; byte ranges slice Blob/File responses. — [src/adapter/web-standard/handler.ts#L60-155](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/handler.ts#L60-L155) [src/adapter/utils.ts#L19-80](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/utils.ts#L19-L80)
- WebSocket frames pass through createWSMessageParser, validation and the message callback; createHandleWSResponse resolves promises, iterates generators and serializes objects before sending. — [src/adapter/bun/index.ts#L589-624](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/index.ts#L589-L624) [src/ws/index.ts#L225-255](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/ws/index.ts#L225-L255) [src/ws/index.ts#L258-305](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/ws/index.ts#L258-L305)

## Behavior traces

The inspected flows cover server startup, request validation and cookie persistence across HTTP boundaries. Additional traces follow shared counter state, native constant responses, WebSockets and file ranges. Execution order includes early returns and adapter-specific conditions. These walkthroughs describe source behavior and test intent; they are not recorded runtime executions.
- Startup: example/counter constructs Elysia, calls state then get, and listen delegates to BunAdapter.listen; that calls compile, builds serving options, invokes Bun.serve, then start hooks and the callback. — [example/counter.ts#L1-6](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/example/counter.ts#L1-L6) [src/index.ts#L8161-8167](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L8161-L8167) [src/adapter/bun/index.ts#L222-235](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/index.ts#L222-L235) [src/adapter/bun/index.ts#L360-396](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/index.ts#L360-L396)
- AOT first request: handle accesses fetch, composeGeneralHandler builds dispatch and installs the error handler, request hooks precede routing, and a route's lazy compile closure calls composeHandler and caches its result. — [src/index.ts#L8092-8110](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L8092-L8110) [src/compose.ts#L2531-2557](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L2531-L2557) [src/index.ts#L918-964](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L918-L964)
- Dynamic POST: createDynamicHandler constructs context, runs request hooks, finds the route, parses JSON, runs transform hooks, validates body, runs beforeHandle, invokes handle and maps its response. — [src/dynamic-handle.ts#L214-290](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L214-L290) [src/dynamic-handle.ts#L549-565](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L549-L565) [src/dynamic-handle.ts#L672-738](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L672-L738) [src/dynamic-handle.ts#L922-935](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L922-L935)
- Invalid-input branch: validateStandardSchema awaits Validate and throws on issues; dynamic dispatch catches the error and delegates to handleError, whose dynamic implementation runs error hooks before its status/message fallback. — [src/dynamic-handle.ts#L189-205](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L189-L205) [src/dynamic-handle.ts#L924-935](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L924-L935) [src/dynamic-handle.ts#L987-1016](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L987-L1016) [src/error.ts#L312-314](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/error.ts#L312-L314)
- Cookie persistence: the /create example assigns name.value; the jar records outgoing changes, AOT encodeCookie signs selected cookies with the first configured key, handleSet serializes them, and later parseCookie verifies keys before decoding values. — [example/cookie.ts#L29-43](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/example/cookie.ts#L29-L43) [src/cookies.ts#L160-187](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/cookies.ts#L160-L187) [src/compose.ts#L630-651](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L630-L651) [src/cookies.ts#L403-453](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/cookies.ts#L403-L453)
- Shared counter: state('counter', 0) populates singleton.store, createContext passes that same store into the request, and the GET handler returns the previous counter value while incrementing it in memory. — [example/counter.ts#L3-6](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/example/counter.ts#L3-L6) [src/index.ts#L7136-7140](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L7136-L7140) [src/adapter/web-standard/index.ts#L169-183](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/index.ts#L169-L183)
- Native constant response: add asks createNativeStaticHandler for a literal handler, that helper rejects nonempty pipeline hooks, and BunAdapter refuses native static route assembly when request hooks, tracing or higher-order wrappers exist. — [src/index.ts#L873-911](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L873-L911) [src/adapter/bun/handler-native.ts#L7-43](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/handler-native.ts#L7-L43) [src/adapter/bun/index.ts#L264-272](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/index.ts#L264-L272)
- File range request: mapResponse dispatches Blob/File to handleFile; a bytes range is parsed and clamped, invalid positions return 416, and valid positions produce a sliced 206 response with range/length headers. — [src/adapter/web-standard/handler.ts#L74-81](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/handler.ts#L74-L81) [src/adapter/utils.ts#L19-80](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/utils.ts#L19-L80) [test/response/range.test.ts#L18-70](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/response/range.test.ts#L18-L70)

## Testing signals

Tests and CI were inspected, not executed; no passing result is asserted. Bun tests exercise request behavior and regressions, while a separate TypeScript project checks public inference. Node and Cloudflare scripts provide integration smoke checks with narrower assertions. The inspected inventory is bounded, and commented tests identify local coverage limits without establishing repository-wide absence.
- The documented unit framework is bun:test with files under test; CONTRIBUTING recommends bun test test/<test-file>.ts for a focused check. — [CONTRIBUTING.md#L19-24](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/CONTRIBUTING.md#L19-L24) [test/core/dynamic.test.ts#L1-6](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/core/dynamic.test.ts#L1-L6)
- Tests and CI were inspected, not executed: the aggregate test script chains functionality, type and Node checks, and CI separately invokes Cloudflare checks after building. — [package.json#L179-185](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/package.json#L179-L185) [.github/workflows/ci.yml#L24-31](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/.github/workflows/ci.yml#L24-L31)
- Dynamic-mode tests explicitly configure aot:false and assert JSON body validation, derive/resolve context and invalid-input 422 behavior. — [test/core/dynamic.test.ts#L24-44](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/core/dynamic.test.ts#L24-L44) [test/core/dynamic.test.ts#L122-151](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/core/dynamic.test.ts#L122-L151)
- Standard Schema integration tests check valid and invalid Zod bodies, coerced queries and combined status-specific responses; validator unit tests insist Check returns booleans rather than truthy failure wrappers. — [test/standard-schema/validate.test.ts#L7-46](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/standard-schema/validate.test.ts#L7-L46) [test/standard-schema/validate.test.ts#L131-181](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/standard-schema/validate.test.ts#L131-L181) [test/units/get-schema-validator.test.ts#L21-43](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/units/get-schema-validator.test.ts#L21-L43)
- Native-static regressions assert promotion refusal for request schemas and observing hooks, preserve eligible constant routes, and require request hooks to remain uncalled during registration. — [test/core/native-static.test.ts#L83-164](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/core/native-static.test.ts#L83-L164)
- Cookie tests exercise signature verification and key rotation; range tests check open-ended, bounded, suffix and invalid ranges, explicitly accepting only the first range of a multi-range request. — [test/cookie/signature.test.ts#L31-67](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/cookie/signature.test.ts#L31-L67) [test/cookie/signature.test.ts#L120-135](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/cookie/signature.test.ts#L120-L135) [test/response/range.test.ts#L18-80](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/response/range.test.ts#L18-L80)
- Type tests use expect-type and tsc with test/types as the configured include; Node CJS/ESM fixtures each validate a simple typed GET through app.handle, while Cloudflare polls only the root response. — [test/types/lifecycle/soundness.ts#L1-28](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/types/lifecycle/soundness.ts#L1-L28) [tsconfig.test.json#L104-105](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/tsconfig.test.json#L104-L105) [test/node/esm/index.js#L12-24](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/node/esm/index.js#L12-L24) [test/cloudflare/script/test.ts#L7-24](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/cloudflare/script/test.ts#L7-L24)
- Local coverage limits include commented cookie decoding cases, dynamic query-reference cases and a WebSocket subscribe/publish case; active WebSocket tests do exercise a real listen(0) connection. — [test/cookie/signature.test.ts#L70-118](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/cookie/signature.test.ts#L70-L118) [test/core/dynamic.test.ts#L718-760](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/core/dynamic.test.ts#L718-L760) [test/ws/message.test.ts#L7-30](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/ws/message.test.ts#L7-L30) [test/ws/message.test.ts#L59-85](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/ws/message.test.ts#L59-L85)

## Risk map

The main sensitive boundaries are generated code, cookie signatures, validation output, filesystem reads and WebSocket validation. Native static routing introduces a separate execution boundary that existing guards and regressions explicitly protect. Several implementation differences merit targeted investigation across runtimes and AOT modes. These are source observations or labeled hypotheses, not confirmed vulnerabilities.
- AOT executes generated JavaScript through Function, and compilation failures log generated instructions, hook source and definitions before potentially exiting the process; this is a broad failure and diagnostic boundary. — [src/compose.ts#L2174-2186](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L2174-L2186) [src/compose.ts#L2220-2266](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L2220-L2266) [src/compose.ts#L2554-2571](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L2554-L2571)
- Hypothesis: compilation diagnostics could expose cookie signing material because encodeCookie embeds the configured secret in generated code and the failure logger prints fnLiteral; no failure was induced. (inferred) — [src/compose.ts#L630-651](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L630-L651) [src/compose.ts#L2223-2228](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L2223-L2228)
- Cookie verification uses crypto.timingSafeEqual when available but falls back to string equality otherwise; HMAC generation uses Web Crypto SHA-256 and Buffer-based base64 encoding. — [src/utils.ts#L656-716](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/utils.ts#L656-L716)
- file(path) passes the supplied path to Bun.file or Node createReadStream/stat without a root restriction in this constructor; applications exposing request-derived paths must establish their own boundary. — [src/universal/file.ts#L94-104](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/universal/file.ts#L94-L104) [src/universal/file.ts#L145-153](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/universal/file.ts#L145-L153)
- Native promotion bypasses the composed request pipeline; isEmptyPipelineHook rejects substantive hooks/schemas, while start, stop, error and afterResponse are explicitly allowed exceptions. — [src/adapter/bun/handler-native.ts#L7-39](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/handler-native.ts#L7-L39) [test/core/native-static.test.ts#L83-145](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/core/native-static.test.ts#L83-L145)
- Multipart reconstruction has explicit dangerous-key checks in both generated and dynamic nested traversal; duplicated parser implementations make consistent handling of dotted and indexed keys a sensitive edit boundary. — [src/adapter/web-standard/index.ts#L51-59](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/index.ts#L51-L59) [src/adapter/web-standard/index.ts#L90-120](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/index.ts#L90-L120) [src/dynamic-handle.ts#L39-76](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L39-L76)
- Hypothesis: asynchronous Standard Schema WebSocket validators may escape validation because message and response checks read .issues directly from validate(data), whereas HTTP validation awaits Validate; this was not reproduced. (inferred) — [src/adapter/bun/index.ts#L463-468](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/bun/index.ts#L463-L468) [src/ws/index.ts#L18-29](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/ws/index.ts#L18-L29) [src/dynamic-handle.ts#L189-205](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L189-L205)
- Production Standard Schema validation messages still include found:value; separately, dynamic selected-cookie signing requires schema membership and truthy values, while the AOT selected-cookie branch lacks that membership condition. — [src/error.ts#L360-381](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/error.ts#L360-L381) [src/dynamic-handle.ts#L904-918](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L904-L918) [src/compose.ts#L644-651](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L644-L651)

## Extension points

Extensions attach through explicit adapter, plugin, hook, parser, macro and model surfaces. The core owns registration and schema composition, while adapters supply execution literals and output handlers. Context additions and mounted fetch applications support application integration without replacing the framework. Public type inference accompanies these runtime extension contracts.
- ElysiaAdapter defines listen/stop, response mappers, parser/context code generation, error mapping, optional WebSockets, native router integration and beforeCompile. — [src/adapter/types.ts#L10-79](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/types.ts#L10-L79) [src/adapter/types.ts#L80-170](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/types.ts#L80-L170)
- use accepts arrays and promised plugins, resolves function/instance/default-export forms, and ultimately incorporates plugin routes through add. — [src/index.ts#L4961-5014](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L4961-L5014) [src/index.ts#L5234-5237](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L5234-L5237)
- Plugin composition imports decorators, state, models and errors through their public registration methods and merges macro and inference state. — [src/index.ts#L5214-5231](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L5214-L5231)
- on converts functions into HookContainers and assigns local or explicit lifecycle scope; guard can add standalone validators or update scoped schema layers and register lifecycle hooks. — [src/index.ts#L3584-3604](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L3584-L3604) [src/index.ts#L4515-4557](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L4515-L4557)
- macro registers named/object expansions; applyMacro deduplicates by checksum, inserts standalone schemas, supports introspection/detail and recursively expands nested macros with a 16-iteration limit. — [src/index.ts#L5468-5551](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L5468-L5551)
- parser stores named BodyHandlers in ~parser, which generated route handlers receive; model accepts TypeBox and Standard Schema definitions, and type-system exports TypeRegistry and FormatRegistry. — [src/index.ts#L1393-1414](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L1393-L1414) [src/compose.ts#L2213-2218](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L2213-L2218) [src/index.ts#L7677-7713](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L7677-L7713) [src/type-system/index.ts#L679-688](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/type-system/index.ts#L679-L688)
- Context extension separates shared state/decorators from request-derived additions: dynamic derive merges transform results, while resolve merges beforeHandle results and continues without treating them as responses. — [src/index.ts#L241-253](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L241-L253) [src/dynamic-handle.ts#L549-565](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L549-L565) [src/dynamic-handle.ts#L692-710](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L692-L710)
- mount accepts Elysia instances or fetch functions and rewrites prefixed Request paths; higher-order functions wrap generated dispatch through createHoc. — [src/index.ts#L5585-5626](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L5585-L5626) [src/index.ts#L5643-5664](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L5643-L5664) [src/compose.ts#L2334-2346](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L2334-L2346)

## Contributor handoff

This brief is pinned to e037eca710e7ad193be09cc6615ab0dbe54af914 and comes from bounded public-source inspection of more than twelve source files. Tests and CI were inspected, not executed, and test existence does not establish passing behavior. Future edits should preserve execution parity, adapter boundaries and public inference. Repository contribution policies and script side effects need attention before moving beyond read-only analysis.
- Treat validation and routing conclusions as source-backed behavior, not execution results: tests and CI were inspected, not executed, and only selected tests were read. — [test/core/dynamic.test.ts#L24-44](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/core/dynamic.test.ts#L24-L44) [.github/workflows/ci.yml#L24-31](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/.github/workflows/ci.yml#L24-L31)
- For routing changes, read add, its compile/cache closure, composeGeneralHandler and createDynamicHandler together; static tables and dynamic route stores use different representations. — [src/index.ts#L918-1008](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L918-L1008) [src/compose.ts#L2351-2424](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/compose.ts#L2351-L2424) [src/dynamic-handle.ts#L264-278](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/dynamic-handle.ts#L264-L278)
- When checks are authorized, begin with a focused Bun test as CONTRIBUTING documents; relevant starting suites include dynamic-mode, native-static, cookie-signature and range tests. — [CONTRIBUTING.md#L19-24](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/CONTRIBUTING.md#L19-L24) [test/core/dynamic.test.ts#L1-14](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/core/dynamic.test.ts#L1-L14) [test/core/native-static.test.ts#L83-124](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/core/native-static.test.ts#L83-L124) [test/response/range.test.ts#L6-15](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/response/range.test.ts#L6-L15)
- Preserve provider contracts: Standard Schema Check deliberately fails closed for Promise results, while asynchronous callers should use Validate and consume value/issues. — [src/schema.ts#L611-648](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/schema.ts#L611-L648) [test/units/get-schema-validator.test.ts#L21-43](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/units/get-schema-validator.test.ts#L21-L43)
- Public API edits require inference review as well as runtime review: Elysia generics and MacroToContext feed route/context types, and test:types compiles the dedicated test/types project. — [src/index.ts#L190-226](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L190-L226) [src/types.ts#L1044-1075](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/types.ts#L1044-L1075) [package.json#L180-183](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/package.json#L180-L183) [tsconfig.test.json#L104-105](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/tsconfig.test.json#L104-L105)
- Keep runtime checks specific: default adapter choice depends on Bun availability, WebStandard listen throws, Cloudflare precompiles routes, and Node fixtures only smoke-test app.handle. — [src/index.ts#L405-407](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/index.ts#L405-L407) [src/adapter/web-standard/index.ts#L231-237](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/web-standard/index.ts#L231-L237) [src/adapter/cloudflare-worker/index.ts#L45-55](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/src/adapter/cloudflare-worker/index.ts#L45-L55) [test/node/cjs/index.js#L10-25](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/node/cjs/index.js#L10-L25)
- Match tabs, single quotes, no semicolons and no trailing commas; AGENTS requires surgical edits and reading exports/callers, while AI_POLICY requires human-reviewed contributions and rejects fully automated issue/PR creation. — [.prettierrc#L1-7](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/.prettierrc#L1-L7) [AGENTS.md#L18-22](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/AGENTS.md#L18-L22) [AGENTS.md#L50-53](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/AGENTS.md#L50-L53) [AI_POLICY.md#L5-15](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/AI_POLICY.md#L5-L15)
- Do not treat scripts as harmless checks: build removes dist and shells out to tsc, Node/Cloudflare scripts install packages, Cloudflare testing spawns a server, and release publishes the package. — [build.ts#L10-29](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/build.ts#L10-L29) [package.json#L179-189](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/package.json#L179-L189) [test/cloudflare/script/test.ts#L1-24](https://github.com/elysiajs/elysia/blob/e037eca710e7ad193be09cc6615ab0dbe54af914/test/cloudflare/script/test.ts#L1-L24)

Source repository: https://github.com/elysiajs/elysia
Full evidence corpus: https://github.com/Codevetter/codevetter/tree/main/benchmarks/repo-unpacks/elysia.json

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
