CodeVetter · Repo Unpack · Extension points
elysiajs/elysia
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.
- use accepts arrays and promised plugins, resolves function/instance/default-export forms, and ultimately incorporates plugin routes through add.
- Plugin composition imports decorators, state, models and errors through their public registration methods and merges macro and inference state.
- 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.
- 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.
- 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.
- 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.
- mount accepts Elysia instances or fetch functions and rewrites prefixed Request paths; higher-order functions wrap generated dispatch through createHoc.