Concrete IMetadataStore. Decorators call the merge*/add*
methods; the DecoratorPlugin and other consumers read the readonly
controllers, services, and routes maps.
-
addCustomDecorator(record: CustomDecoratorRecord): void
Records a custom decorator for replay at registration time.
-
addRouteBinding(): voidtarget: Constructor,handler: string,method: HttpMethod,path: string
Adds an HTTP verb + path binding to a method (
@Get,@Post, …). -
clear(): void
Removes all stored metadata. Intended for test isolation — decorators applied at module-evaluation time are NOT re-run, so callers that rely on decorated fixtures should not clear between tests using those fixtures.
-
controllers(): Map<Constructor, Readonly<Record<string, unknown>>>
Controllers keyed by class.
-
ctorOptional(target: Constructor): ReadonlySet<number>
Returns the constructor-argument indices a class marked
@Optional. -
getController(target: Constructor): ControllerMetadata | undefined
Returns a class's controller metadata, or
undefined. -
getCustomDecorators(): readonly CustomDecoratorRecord[]
Returns all recorded custom decorators.
-
getMethods(target: Constructor): ReadonlyMap<string, MethodMeta>
Returns the method accumulators for a controller.
-
getModule(target: Constructor): ModuleMetadata | undefined
Returns a class's module declaration, if it has one.
-
getOrCreateMethod(): MethodMetatarget: Constructor,handler: string
Returns the (mutable) method accumulator for a controller method, creating it if absent.
-
getRoutesFor(target: Constructor): RouteMetadata[]
Returns the materialized
RouteMetadataentries for a controller — one per (method, HTTP verb). Unlike theIMetadataStore.routesgetter (loosely typed for external consumers), this returns the concrete shape the plugin composes routes from. -
getService(target: Constructor): ServiceMetadata | undefined
Returns a class's service metadata, or
undefined. -
hasController(target: Constructor): boolean
Reports whether a class has controller metadata.
-
hasService(target: Constructor): boolean
Reports whether a class has service metadata.
-
mergeController(): voidtarget: Constructor,partial: Partial<ControllerMetadata>
Merges a partial into a class's controller metadata, creating it if absent. Arrays append; scalar fields replace.
-
mergeCtorOptional(): voidtarget: Constructor,index: number
Marks one constructor parameter as optional, keyed by its argument index.
-
mergeModule(): voidtarget: Constructor,partial: Partial<ModuleMetadata>
Merges a partial module declaration into a class's metadata.
-
mergeService(): voidtarget: Constructor,partial: Partial<ServiceMetadata>
Merges a partial into a class's service metadata, creating it if absent.
-
mutateMethod(): voidtarget: Constructor,handler: string,mutate: (meta: MethodMeta) => void
Merges a partial into a method's accumulator. Arrays append; scalar fields replace. Parameter decorators append to
params. -
routes(): Map<>Constructor,ReadonlyArray<Readonly<Record<string, unknown>>>
Materialized route metadata, one entry per (controller, HTTP verb). Derived from the internal per-method accumulators so the result is independent of decorator application order.
-
services(): Map<Constructor, Readonly<Record<string, unknown>>>
Services keyed by class.
-
setCtorOptional(): voidtarget: Constructor,indices: Iterable<number>
Replaces a class's optional-argument set outright.
-
storeParam(): voidtarget: Constructor,handler: string,param: ParameterMetadata
Appends a parameter to a method's accumulator.
Describes the OpenAPI operation for a route handler.
Documents a response status for a route handler. May be applied multiple times to describe several responses.
Binds the parsed JSON request body.
Removes a registered custom parameter resolver (intended for tests).
Marks a class as a controller and assigns a base path prefix for all its routes.
Creates a custom class or method decorator that stores metadata readable by the DecoratorPlugin and custom decorator handlers.
Binds the active request context — for a handler that sets its own status code, adds a header, or returns a streaming response.
Binds the authenticated principal (ctx.request.user).
Binds a value produced by an application-registered resolver.
Creates the DecoratorPlugin.
Discovers decorated classes by scanning a directory and importing files.
Returns the resolver registered for a custom parameter type, if any.
Binds a request header value.
Declares the constructor injection tokens for a class, one per constructor
argument in argument order. The DecoratorPlugin resolves each token (from
the DI container or the service registry) and passes the results to the
constructor.
Marks a class as injectable (eligible for DI container registration). When
the DecoratorPlugin runs, injectable classes in its services list (or
discovered) are registered with the DI container when present, or
instantiated directly otherwise.
Groups controllers and providers under one class.
Marks a constructor dependency as optional: when the token has no provider,
the argument receives undefined instead of failing construction.
Binds a path parameter.
Binds handler arguments to request sources, positionally.
Requires the authenticated principal to hold any of the given permissions. May be applied at the class or method level (method overrides class).
Marks an unrestricted route as public in the OpenAPI document: its schema
carries security: [], so a document-level security requirement does not
apply to it.
Binds the whole query record.
Registers a resolver for a custom parameter type created with
a Custom(name) source. current-user resolves directly;
Ctx() uses an internal marker and also resolves directly. Application
custom parameter types, including one named context, use this registry.
A handler may also return a HandlerResult from ctx.response — a
redirect, most usefully — instead of the props bag. That is what makes
POST-redirect-GET expressible on a rendered route: a form handler returns
the props to re-render itself with errors, or ctx.response.redirect(...)
once the submission is accepted. HandlerResult is branded
(__handlerResult: true), so widening the union costs nothing: a props bag
of the wrong shape is still a compile error.
Resolves a single parameter value from the request context. The result may
be a promise (for body and custom resolvers); callers should await it.
Resolves an ordered argument array for a handler from its parameter
metadata. Arguments are placed by parameter index, so undecorated
parameters receive undefined.
Requires the authenticated principal to hold any of the given roles. May be applied at the class level (default for all routes) or method level (overrides the class default).
Attaches error filters to a controller or route. Filters run last in the route middleware chain.
Attaches guards to a controller or route. Guards run before the handler and
may short-circuit by responding without calling next().
Attaches interceptors to a controller or route. Interceptors wrap the
handler invocation (pre- and post-processing via next()).
Attaches a request body schema to the decorated route handler.
Attaches a path parameter schema to the decorated route handler.
Attaches a query parameter schema to the decorated route handler.
Assigns an API version prefix to a controller. Combined with @Controller,
the effective path is version + basePath + routePath
(e.g. '/v1/users').
Configuration for ApiOperation.
-
description: string
Longer description.
-
operationId: string
Operation id.
-
summary: string
Short summary.
Configuration for ApiResponse.
-
description: string
Response description.
-
schema: unknown
Response body schema.
-
status: number
HTTP status code.
Options for DecoratorPlugin.
-
autoDiscover: boolean
When
true, auto-scancontrollersPathfor decorated classes. Discovery failures are logged as warnings and never crash the application. -
controllers: readonly Constructor[]
Explicit list of controller classes to register.
-
controllersPath: string
Glob path for controller discovery (used when
autoDiscoveristrue). -
enforceRoles: boolean
When
true(the default), a route decorated with@Roles/@Permissionsgets enforcing authorization middleware appended to its chain — after the route's guards and filters, before any validation middleware. The middleware resolvesCAPABILITIES.AUTHORIZATIONper request: with a provider registered it answers401/403exactly like the equivalent@UseGuards(requireRole(...))spelling; with none, the route FAILS CLOSED — it answers501and is never served unguarded — andregister()warns once per affected route. -
enforceSchemas: boolean
When
true(the default), a route decorated with@ValidateBody/@ValidateQuery/@ValidateParamsgets the registered validation capability's enforcing middleware appended LAST in its chain (innermost, after guards and filters), so an invalid request is rejected with400before the handler runs — while guard401/403precedence is preserved. -
modules: readonly Constructor[]
Module classes to expand before registration. Imported modules are visited depth-first; each module's providers are collected before its controllers.
-
services: readonly Constructor[]
Explicit list of service classes to register.
Discovery configuration.
-
exclude: readonly string[]
Glob patterns to exclude (default: test/spec files).
-
extensions: readonly string[]
File extensions to include (default:
['.ts', '.mts', '.js', '.mjs']). -
path: string
Directory path to scan (relative or absolute).
Result of a discovery scan.
-
controllers: readonly Constructor[]
Discovered controller classes.
-
errors: ReadonlyArray<{ readonly file: string; readonly error: string; }>
Files that failed to import, with error messages.
-
services: readonly Constructor[]
Discovered service classes.
Options for Injectable.
-
scope: ServiceScope
Lifecycle scope.
-
token: string
Capability token to register the service under.
What a @Module declares.
-
controllers: readonly Constructor[]
Controller classes this module contributes.
-
imports: readonly Constructor[]
Other modules that this module includes.
-
providers: readonly Constructor[]
Provider classes this module contributes.
A token marked optional by Optional.
-
optional: true
Discriminator marking this dependency as optional.
-
token: string
The capability token to resolve.
Metadata captured by a parameter decorator, later resolved by the
resolveParameters function.
-
customType: string
Custom parameter type name (from a
Custom(name)source). -
index: number
Positional index of the parameter in the handler signature.
-
metadata: Readonly<Record<string, unknown>>
Extra payload captured by a custom parameter decorator.
-
name: string
Name for named sources (
@Query('page'),@Param('id'), …). -
type: ParameterType
Source of the parameter value.
A declaration of where one handler argument comes from.
-
__value: T
Phantom carrier for the resolved value type. Never present at runtime.
-
descriptor: Omit<ParameterMetadata, "index">
The metadata this source contributes, less its positional index.
Resolves a custom parameter value (from
a Custom(name) source) at request time.
A factory producing a method decorator that registers a route for a given HTTP verb.
A constructor dependency: a capability token, or a token wrapped by
Optional.
A middleware value accepted by pipeline decorators: either a bare
MiddlewareFunction or a class implementing
IMiddleware.
Loads a module from a specifier. Defaults to the global dynamic import;
injectable for tests.
Where a request parameter is sourced from.
The decorator Render(Component) returns: assignable to a handler whose
return is the component's props bag, sync or async, with any parameter
list. A handler returning the WRONG shape fails compilation naming the
mismatch — strictly stronger than NestJS's @Render('users/index'), a
string checked against nothing.
A standard class decorator that records metadata and leaves the class as it is. Returning nothing means the class is never replaced, which is what keeps a decorated class identical to its undecorated self at runtime.
A standard decorator valid in either the class or the method position,
discriminating on context.kind.
A standard method decorator that records metadata and leaves the method as it is.
Maps a tuple of sources onto the handler parameter tuple they bind.
Registers a DELETE route on the decorated method.
Registers a GET route on the decorated method.
Registers a HEAD route on the decorated method.
The process-wide singleton decorators write to. The DecoratorPlugin
registers this same instance under CAPABILITIES.METADATA_STORE so
ctx.metadata resolves to it.
Registers an OPTIONS route on the decorated method.
Registers a PATCH route on the decorated method.
Registers a POST route on the decorated method.
Registers a PUT route on the decorated method.
Usage
import * as Optional_decorator_and_metadata_system_plugin___Provides_NestJS_style_decorators____Controller_____Get_____Params______as_syntactic_sugar_over_the_kernel_s_programmatic_API__Decorators_capture_metadata_in_a_plain___linkcode_MetadataStore___the__DecoratorPlugin__reads_that_store_at_registration_time_and_registers_routes__services__and_middleware_with_the_kernel__No_reflection___reflect_metadata___is_required__and_decorators_are_inert_unless_the__DecoratorPlugin__is_registered___Every_export_here_is_public_API_and_documented_in_PUBLIC_API_md__AI_GUIDELINES__10__ from "decorator-plugin/src/index.ts";