nest

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
NestJS is a progressive Node.js framework for building efficient and scalable server-side applications. It uses TypeScript by default, supports both Express and Fastify, and provides an out-of-the-box application architecture inspired by Angular. NestJS combines elements of OOP, FP, and FRP, making it ideal for building enterprise-grade applications.
The skill is based on NestJS documentation, generated at 2026-02-01.
NestJS 是一款渐进式 Node.js 框架,用于构建高效、可扩展的服务端应用。它默认使用 TypeScript,同时支持 Express 和 Fastify,并提供了受 Angular 启发的开箱即用的应用架构。NestJS 融合了 OOP(面向对象编程)、FP(函数式编程)和 FRP(函数响应式编程)的特性,非常适合构建企业级应用。
本技能基于 NestJS 文档生成,生成时间为 2026-02-01。

CLI

CLI

TopicDescriptionReference
CLI OverviewScaffolding, building, and running applicationscli-overview
Monorepo & LibrariesWorkspaces, apps, shared librariescli-monorepo
主题描述参考链接
CLI 概述脚手架搭建、构建及运行应用cli-overview
单仓库与库工作区、应用、共享库cli-monorepo

Core References

核心参考

TopicDescriptionReference
ControllersRoute handlers, HTTP methods, request/response handlingcore-controllers
ModulesApplication structure, feature modules, shared modules, dynamic modulescore-modules
ProvidersServices, dependency injection, custom providerscore-providers
Dependency InjectionDI fundamentals, custom providers, scopescore-dependency-injection
MiddlewareRequest/response middleware, functional middlewarecore-middleware
主题描述参考链接
控制器路由处理器、HTTP 方法、请求/响应处理core-controllers
模块应用结构、功能模块、共享模块、动态模块core-modules
提供者服务、依赖注入、自定义提供者core-providers
依赖注入DI 基础、自定义提供者、作用域core-dependency-injection
中间件请求/响应中间件、函数式中间件core-middleware

Fundamentals

基础特性

TopicDescriptionReference
PipesData transformation and validation pipesfundamentals-pipes
GuardsAuthorization guards, role-based access controlfundamentals-guards
InterceptorsAspect-oriented programming, response transformationfundamentals-interceptors
Exception FiltersError handling, custom exception filtersfundamentals-exception-filters
Custom DecoratorsCreating custom parameter decoratorsfundamentals-custom-decorators
Dynamic ModulesConfigurable modules, module configurationfundamentals-dynamic-modules
Execution ContextAccessing request context, metadata reflectionfundamentals-execution-context
Provider ScopesSingleton, request-scoped, transient providersfundamentals-provider-scopes
Lifecycle EventsApplication and provider lifecycle hooksfundamentals-lifecycle-events
Lazy LoadingLoading modules on-demand for serverlessfundamentals-lazy-loading
Circular DependencyResolving circular dependencies with forwardReffundamentals-circular-dependency
Module ReferenceAccessing providers dynamically with ModuleReffundamentals-module-reference
TestingUnit testing and e2e testing with @nestjs/testingfundamentals-testing
主题描述参考链接
管道数据转换与验证管道fundamentals-pipes
守卫授权守卫、基于角色的访问控制fundamentals-guards
拦截器面向切面编程、响应转换fundamentals-interceptors
异常过滤器错误处理、自定义异常过滤器fundamentals-exception-filters
自定义装饰器创建自定义参数装饰器fundamentals-custom-decorators
动态模块可配置模块、模块配置fundamentals-dynamic-modules
执行上下文访问请求上下文、元数据反射fundamentals-execution-context
提供者作用域单例、请求作用域、临时提供者fundamentals-provider-scopes
生命周期事件应用与提供者生命周期钩子fundamentals-lifecycle-events
懒加载为无服务器架构按需加载模块fundamentals-lazy-loading
循环依赖使用 forwardRef 解决循环依赖fundamentals-circular-dependency
模块引用使用 ModuleRef 动态访问提供者fundamentals-module-reference
测试使用 @nestjs/testing 进行单元测试与端到端测试fundamentals-testing

Techniques

技术实践

TopicDescriptionReference
ValidationValidationPipe, class-validator, DTO validationtechniques-validation
ConfigurationEnvironment variables, ConfigModule, configuration managementtechniques-configuration
DatabaseTypeORM, Prisma, MongoDB integrationtechniques-database
CachingCache manager, Redis integration, auto-cachingtechniques-caching
LoggingBuilt-in logger, custom loggers, JSON loggingtechniques-logging
File UploadFile upload handling with multer, validationtechniques-file-upload
VersioningURI, header, and media type API versioningtechniques-versioning
SerializationResponse serialization with class-transformertechniques-serialization
QueuesBackground job processing with BullMQtechniques-queues
Task SchedulingCron jobs, intervals, and timeoutstechniques-task-scheduling
EventsEvent-driven architecture with EventEmittertechniques-events
HTTP ModuleMaking HTTP requests with Axiostechniques-http-module
FastifyUsing Fastify for better performancetechniques-fastify
Sessions & CookiesHTTP sessions and cookies for stateful appstechniques-sessions-cookies
Streaming & SSECompression, file streaming, Server-Sent Eventstechniques-compression-streaming-sse
MVC & Serve StaticTemplate rendering (Handlebars) and SPA static servingtechniques-mvc-serve-static
主题描述参考链接
验证ValidationPipe、class-validator、DTO 验证techniques-validation
配置环境变量、ConfigModule、配置管理techniques-configuration
数据库TypeORM、Prisma、MongoDB 集成techniques-database
缓存缓存管理器、Redis 集成、自动缓存techniques-caching
日志内置日志器、自定义日志器、JSON 日志techniques-logging
文件上传使用 multer 处理文件上传、验证techniques-file-upload
版本控制URI、请求头、媒体类型 API 版本控制techniques-versioning
序列化使用 class-transformer 进行响应序列化techniques-serialization
队列使用 BullMQ 处理后台任务techniques-queues
任务调度Cron 任务、间隔任务与超时任务techniques-task-scheduling
事件基于 EventEmitter 的事件驱动架构techniques-events
HTTP 模块使用 Axios 发起 HTTP 请求techniques-http-module
Fastify使用 Fastify 提升性能techniques-fastify
会话与 Cookie为有状态应用提供 HTTP 会话与 Cookietechniques-sessions-cookies
流与 SSE压缩、文件流、服务器发送事件techniques-compression-streaming-sse
MVC 与静态资源服务模板渲染(Handlebars)与 SPA 静态资源服务techniques-mvc-serve-static

Security

安全

TopicDescriptionReference
AuthenticationPassport integration, JWT authenticationrecipes-authentication
AuthorizationRBAC, claims-based, CASL integrationsecurity-authorization
CORS & Rate LimitingCORS, Helmet, ThrottlerModulesecurity-cors-helmet-rate-limiting
Encryption & Hashingbcrypt, argon2, password hashingsecurity-encryption-hashing
主题描述参考链接
身份认证Passport 集成、JWT 身份认证recipes-authentication
授权RBAC、基于声明的授权、CASL 集成security-authorization
CORS 与速率限制CORS、Helmet、ThrottlerModulesecurity-cors-helmet-rate-limiting
加密与哈希bcrypt、argon2、密码哈希security-encryption-hashing

OpenAPI

OpenAPI

TopicDescriptionReference
SwaggerOpenAPI documentation generationopenapi-swagger
主题描述参考链接
SwaggerOpenAPI 文档生成openapi-swagger

WebSockets

WebSockets

TopicDescriptionReference
GatewaysReal-time communication with Socket.IO/wswebsockets-gateways
Guards & Exception FiltersWsException, BaseWsExceptionFilter, interceptors, pipeswebsockets-advanced
主题描述参考链接
网关使用 Socket.IO/ws 实现实时通信websockets-gateways
守卫与异常过滤器WsException、BaseWsExceptionFilter、拦截器、管道websockets-advanced

Microservices

微服务

TopicDescriptionReference
OverviewTransport layers, message patterns, eventsmicroservices-overview
gRPCProtocol Buffers, streaming, metadata, reflectionmicroservices-grpc
TransportsRedis, Kafka, NATS, RabbitMQ configurationmicroservices-transports
主题描述参考链接
概述传输层、消息模式、事件microservices-overview
gRPCProtocol Buffers、流、元数据、反射microservices-grpc
传输层Redis、Kafka、NATS、RabbitMQ 配置microservices-transports

GraphQL

GraphQL

TopicDescriptionReference
OverviewCode-first and schema-first approachesgraphql-overview
Resolvers & MutationsQueries, mutations, field resolversgraphql-resolvers-mutations
SubscriptionsReal-time subscriptions with PubSubgraphql-subscriptions
Scalars, Unions & EnumsInterfaces, scalars, union types, enumsgraphql-scalars-unions-enums
主题描述参考链接
概述代码优先与架构优先方案graphql-overview
解析器与变更查询、变更、字段解析器graphql-resolvers-mutations
订阅使用 PubSub 实现实时订阅graphql-subscriptions
标量、联合类型与枚举接口、标量、联合类型、枚举graphql-scalars-unions-enums

Recipes

实践方案

TopicDescriptionReference
CRUD GeneratorNest CLI resource generatorrecipes-crud-generator
DocumentationOpenAPI/Swagger integrationrecipes-documentation
TypeORMTypeORM integration and usagerecipes-typeorm
PrismaPrisma ORM integrationrecipes-prisma
MongooseMongoDB with Mongoose ODMrecipes-mongoose
CQRSCommand Query Responsibility Segregationrecipes-cqrs
TerminusHealth checks and readiness/liveness probesrecipes-terminus
主题描述参考链接
CRUD 生成器Nest CLI 资源生成器recipes-crud-generator
文档OpenAPI/Swagger 集成recipes-documentation
TypeORMTypeORM 集成与使用recipes-typeorm
PrismaPrisma ORM 集成recipes-prisma
Mongoose使用 Mongoose ODM 操作 MongoDBrecipes-mongoose
CQRS命令查询职责分离recipes-cqrs
Terminus健康检查与就绪/存活探针recipes-terminus

FAQ

常见问题

TopicDescriptionReference
Raw Body & HybridWebhook signature verification, HTTP + microservicesfaq-raw-body-hybrid
主题描述参考链接
原始请求体与混合架构Webhook 签名验证、HTTP + 微服务faq-raw-body-hybrid

Best Practices

最佳实践

TopicDescriptionReference
Request LifecycleUnderstanding execution order and flowbest-practices-request-lifecycle
主题描述参考链接
请求生命周期理解执行顺序与流程best-practices-request-lifecycle