Classes

c
MetadataStore

Concrete IMetadataStore. Decorators call the merge*/add* methods; the DecoratorPlugin and other consumers read the readonly controllers, services, and routes maps.

Functions

f
ApiOperation(config: ApiOperationConfig): SetuMethodDecorator

Describes the OpenAPI operation for a route handler.

f
ApiResponse(config: ApiResponseConfig): SetuMethodDecorator

Documents a response status for a route handler. May be applied multiple times to describe several responses.

f
ApiTags(...tags: string[]): SetuClassDecorator

Assigns OpenAPI tags to a controller. Tags are inherited by every route in the controller and merged with any method-level tags.

f
Body<T = unknown>(): ParamSource<T>

Binds the parsed JSON request body.

f
clearParameterResolvers(): void

Removes a registered custom parameter resolver (intended for tests).

f
Controller(path: string): SetuClassDecorator

Marks a class as a controller and assigns a base path prefix for all its routes.

f
createDecorator(
name: string,
metadata: Readonly<Record<string, unknown>>
): SetuClassOrMethodDecorator

Creates a custom class or method decorator that stores metadata readable by the DecoratorPlugin and custom decorator handlers.

f
Ctx(): ParamSource<IRequestContext>

Binds the active request context — for a handler that sets its own status code, adds a header, or returns a streaming response.

f
CurrentUser<T = unknown>(): ParamSource<T>

Binds the authenticated principal (ctx.request.user).

f
getParameterResolver(name: string): CustomParameterResolver | undefined

Returns the resolver registered for a custom parameter type, if any.

f
Inject(...tokens: readonly InjectToken[]): SetuClassDecorator

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.

f
Injectable(options?: InjectableOptions): SetuClassDecorator

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.

f
Module(options: ModuleOptions): SetuClassDecorator

Groups controllers and providers under one class.

f
Optional(token: string): OptionalToken

Marks a constructor dependency as optional: when the token has no provider, the argument receives undefined instead of failing construction.

f
parseCookies(headers: Headers): Record<string, string>

Parses cookies from a Cookie request header into a name→value record.

f
Permissions(...permissions: string[]): SetuClassOrMethodDecorator

Requires the authenticated principal to hold any of the given permissions. May be applied at the class or method level (method overrides class).

f
Public(): SetuMethodDecorator

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.

f
registerParameterResolver(
name: string,
resolver: CustomParameterResolver
): void

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.

f
Render<P>(component: Component<P>): RenderDecorator<P>

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.

f
resolveParameter(
ctx: IRequestContext,
param: ParameterMetadata
): unknown | Promise<unknown>

Resolves a single parameter value from the request context. The result may be a promise (for body and custom resolvers); callers should await it.

f
resolveParameters(
ctx: IRequestContext,
params: readonly ParameterMetadata[]
): Promise<unknown[]>

Resolves an ordered argument array for a handler from its parameter metadata. Arguments are placed by parameter index, so undecorated parameters receive undefined.

f
Roles(...roles: string[]): SetuClassOrMethodDecorator

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).

f
UseFilters(...middlewares: MiddlewareLike[]): SetuClassOrMethodDecorator

Attaches error filters to a controller or route. Filters run last in the route middleware chain.

f
UseGuards(...middlewares: MiddlewareLike[]): SetuClassOrMethodDecorator

Attaches guards to a controller or route. Guards run before the handler and may short-circuit by responding without calling next().

f
UseInterceptors(...middlewares: MiddlewareLike[]): SetuClassOrMethodDecorator

Attaches interceptors to a controller or route. Interceptors wrap the handler invocation (pre- and post-processing via next()).

f
ValidateBody(schema: unknown): SetuMethodDecorator

Attaches a request body schema to the decorated route handler.

f
ValidateParams(schema: unknown): SetuMethodDecorator

Attaches a path parameter schema to the decorated route handler.

f
ValidateQuery(schema: unknown): SetuMethodDecorator

Attaches a query parameter schema to the decorated route handler.

f
Version(version: string): SetuClassDecorator

Assigns an API version prefix to a controller. Combined with @Controller, the effective path is version + basePath + routePath (e.g. '/v1/users').

Interfaces

I
ApiOperationConfig

Configuration for ApiOperation.

I
ApiResponseConfig

Configuration for ApiResponse.

I
DecoratorPluginOptions

Options for DecoratorPlugin.

  • autoDiscover: boolean

    When true, auto-scan controllersPath for 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 autoDiscover is true).

  • enforceRoles: boolean

    When true (the default), a route decorated with @Roles / @Permissions gets enforcing authorization middleware appended to its chain — after the route's guards and filters, before any validation middleware. The middleware resolves CAPABILITIES.AUTHORIZATION per request: with a provider registered it answers 401/403 exactly like the equivalent @UseGuards(requireRole(...)) spelling; with none, the route FAILS CLOSED — it answers 501 and is never served unguarded — and register() warns once per affected route.

  • enforceSchemas: boolean

    When true (the default), a route decorated with @ValidateBody / @ValidateQuery / @ValidateParams gets the registered validation capability's enforcing middleware appended LAST in its chain (innermost, after guards and filters), so an invalid request is rejected with 400 before the handler runs — while guard 401/403 precedence 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.

I
DiscoveryOptions

Discovery configuration.

I
DiscoveryResult

Result of a discovery scan.

I
InjectableOptions

Options for Injectable.

I
ModuleOptions

What a @Module declares.

I
OptionalToken

A token marked optional by Optional.

I
ParameterMetadata

Metadata captured by a parameter decorator, later resolved by the resolveParameters function.

I
ParamSource

A declaration of where one handler argument comes from.

Type Aliases

T
HttpMethodDecorator = (path?: string) => SetuMethodDecorator

A factory producing a method decorator that registers a route for a given HTTP verb.

T
InjectToken = string | OptionalToken

A constructor dependency: a capability token, or a token wrapped by Optional.

T
MiddlewareLike = MiddlewareFunction | (new () => IMiddleware)

A middleware value accepted by pipeline decorators: either a bare MiddlewareFunction or a class implementing IMiddleware.

T
ModuleImporter = (specifier: string) => Promise<unknown>

Loads a module from a specifier. Defaults to the global dynamic import; injectable for tests.

T
RenderDecorator<P> = (
value: (...args: never[]) => P | HandlerResult | Promise<P | HandlerResult>,
context: ClassMethodDecoratorContext
) => void

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.

T
SetuClassDecorator = (
value: unknown,
context: ClassDecoratorContext
) => void

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.

T
SetuClassOrMethodDecorator = (
value: unknown,
context: ClassDecoratorContext | ClassMethodDecoratorContext
) => void

A standard decorator valid in either the class or the method position, discriminating on context.kind.

T
SetuMethodDecorator = (
value: unknown,
context: ClassMethodDecoratorContext
) => void

A standard method decorator that records metadata and leaves the method as it is.

Variables

v
Delete: HttpMethodDecorator

Registers a DELETE route on the decorated method.

v
Get: HttpMethodDecorator

Registers a GET route on the decorated method.

v
Head: HttpMethodDecorator

Registers a HEAD route on the decorated method.

v
metadataStore: MetadataStore

The process-wide singleton decorators write to. The DecoratorPlugin registers this same instance under CAPABILITIES.METADATA_STORE so ctx.metadata resolves to it.

v
Options: HttpMethodDecorator

Registers an OPTIONS route on the decorated method.

v
Patch: HttpMethodDecorator

Registers a PATCH route on the decorated method.

v
Post: HttpMethodDecorator

Registers a POST route on the decorated method.

v
Put: HttpMethodDecorator

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";