一键导入
getting-started
Use when building Express routes with validated body and query DTOs plus standardized error responses.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when building Express routes with validated body and query DTOs plus standardized error responses.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when scanning NestJS providers with DiscoveryService-backed utilities.
Use when working with the @wisemen/nestjs-custom-fields package — developer-defined custom fields in NestJS with TypeORM persistence and runtime validation. Covers registering the CustomFieldDefinition entity, authoring definitions with customFieldDefinition(), storing resolved values via @CustomFieldValueColumn(), exposing them through CustomFieldValueDto / @IsCustomFields(), and validating submissions with CustomFieldDefinitionsRepository + validateCustomFieldValues(). Use this whenever a task involves custom field definitions, CustomFieldValue columns, custom-field DTOs, or tenant-scoped field definitions, even if the package is not named explicitly.
Use when defining Typesense collections, collectors, and search queries in NestJS APIs.
Generate PDFs through API2PDF in NestJS. Use when converting HTML or URLs to PDFs in apis.
Use when storing and validating multilingual text in NestJS apis with TypeORM and class-validator.
Use when configuring NATS messaging, subscribers, or the simple NatsClient in NestJS applications.
| name | getting-started |
| description | Use when building Express routes with validated body and query DTOs plus standardized error responses. |
Use DtoRouter when an Express route should validate request DTOs before it reaches the controller. Extend Dto for request models, register them in dtos, and throw CustomError for client-facing failures.
import { IsOptional, IsString } from 'class-validator'
import express from 'express'
import {
ControllerOptions,
CustomError,
Dto,
DtoRouter,
} from '@appwise/express-dto-router'
class CreateUserBodyDto extends Dto {
@IsString()
name: string
@IsOptional()
@IsString()
role?: string
}
class ListUsersQueryDto extends Dto {
@IsOptional()
@IsString()
search?: string
}
class UsersController {
async createUser (
{ body, query }: ControllerOptions<{ body: CreateUserBodyDto, query: ListUsersQueryDto }>
) {
if (body.name === 'blocked') {
throw new CustomError('validation_error')
}
return {
name: body.name,
search: query?.search ?? null
}
}
}
const controller = new UsersController()
const router = new DtoRouter()
router.post({
path: '/users',
dtos: {
body: CreateUserBodyDto,
query: ListUsersQueryDto
},
controller: controller.createUser.bind(controller)
})
router.uuidParam('userUuid')
const app = express()
app.use(express.json())
app.use(router.router)
app.use((err, req, res, _next) => {
DtoRouter.handleError(err, req, res).catch(console.error)
})
Use groups inside dtos when the same DTO class needs different validation rules per route. Return ApiResponse instead of plain JSON when the route must control headers or status handling explicitly.