Pipeline
Attach guards, middleware, interceptors, pipes, and filters to a handler
These decorators attach request pipeline stages to a handler, or to every handler in a class. They run in a fixed order: guards, middleware, interceptors, pipes, then the handler, with filters catching errors.
@UseGuards
Applies guards for authentication and authorization.
import { UseGuards } from '@nitrostack/core';
@UseGuards(...guards: GuardConstructor[])@use_guards(...)Example:
@Tool({ name: 'admin_action' })
@UseGuards(JWTGuard, AdminGuard)
async adminAction(input: AdminInput, ctx: ExecutionContext) {
// Only authenticated admins can access
}@UseMiddleware
Applies middleware for cross-cutting concerns.
import { UseMiddleware } from '@nitrostack/core';
@UseMiddleware(...middleware: MiddlewareConstructor[])@use_middleware(...)Example:
@Tool({ name: 'tracked_operation' })
@UseMiddleware(LoggingMiddleware, TimingMiddleware)
async trackedOperation(input: OperationInput, ctx: ExecutionContext) {
// Middleware runs before and after
}@UseInterceptors
Applies interceptors for response transformation.
import { UseInterceptors } from '@nitrostack/core';
@UseInterceptors(...interceptors: InterceptorConstructor[])@use_interceptors(...)Example:
@Tool({ name: 'get_data' })
@UseInterceptors(ResponseWrapperInterceptor, DataMaskingInterceptor)
async getData(input: DataInput, ctx: ExecutionContext) {
return { sensitiveField: 'value' };
// Response transformed and masked by interceptors
}@UsePipes
Applies pipes for input validation and transformation.
import { UsePipes } from '@nitrostack/core';
@UsePipes(...pipes: PipeConstructor[])@use_pipes(...)Example:
@Tool({ name: 'search' })
@UsePipes(TrimPipe, ValidationPipe)
async search(input: { query: string }, ctx: ExecutionContext) {
// Input is trimmed and validated
}@UseFilters
Applies exception filters for error handling.
import { UseFilters } from '@nitrostack/core';
@UseFilters(...filters: ExceptionFilterConstructor[])@use_filters(...)Example:
@Tool({ name: 'risky_operation' })
@UseFilters(GlobalExceptionFilter)
async riskyOperation(input: RiskyInput, ctx: ExecutionContext) {
// Errors caught and formatted by filter
}