CodeVetter · Repo Unpack · Data flow
elysiajs/elysia
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.
- WebStandard createContext extracts URL path/query positions, shares store and decorator values, and allocates request-local set headers/status.
- Dynamic dispatch runs application request hooks first, then searches method, WebSocket method and ALL routes; missing routes receive parsed query context before NotFoundError.
- 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.
- Standard Schema Validate propagates value/issues results and awaits Promise results; dynamic HTTP validation replaces context fields with validated output or throws ValidationError.
- 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.
- 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.
- WebSocket frames pass through createWSMessageParser, validation and the message callback; createHandleWSResponse resolves promises, iterates generators and serializes objects before sending.