Skip to main content

API reference

Decorators

DecoratorKindDescription
@Controller(prefix?)classRegisters the controller and its route prefix.
@Get/@Post/@Put/@Patch/@Delete/@Head/@Options(path?)methodBind a method to an HTTP verb + path.
@All(path?)methodBind a method to every HTTP verb.
@Use(middleware)methodAttach middleware to a single route.
@Body(DtoClass)parameterParse + validate the JSON body, inject the DTO instance.
@AuthGuard(roles?)methodRequire context.user (optionally role-matching); 401/403 otherwise. Sugar over @Use. See Authentication guards.
@CurrentUser()parameterInject context.user (or null); never blocks on its own.
@ApiTags(...tags)classGroup a controller's routes under a tag in the OpenAPI doc.
@ApiOperation({ summary?, description? })methodHuman-readable summary/description for a route.
@ApiResponse({ status, description, type?, isArray? })methodDocument a possible response (repeatable).

Functions

ExportSignatureDescription
createApplication(options: ApplicationOptions) => NextJsAppBuilds the router that dispatches to your registered controllers. See Application configuration.
generateOpenApiDocument(options?: GenerateOpenApiDocumentOptions) => objectBuilds an OpenAPI 3.0 document from your decorator metadata. See OpenAPI / Swagger docs.
createSwaggerUiHandler(options?: SwaggerUiOptions) => RouteHandlerReturns a GET handler that serves the Swagger UI + its static assets.
registerController(app: NextJsApp, ControllerClass) => voidLower-level primitive createApplication uses internally.

Types

RouteContext, NextJsApp, Middleware, RouteHandler, ApplicationOptions, RouteDefinition, RouteMiddleware, ApiOperationMeta, ApiResponseMeta, GenerateOpenApiDocumentOptions, SwaggerUiOptions are all exported for consumers who want to type their own helpers around them.

RouteContext carries a mutable user field — middleware sets it, and @AuthGuard/@CurrentUser read it. See Authentication guards.

Response helper

See Handler return values for the full list of Response.* static methods.