用途:在 Bun 运行时上开发 Fastify 5.x + TypeScript 后端服务,适用于新建后端 API、添加路由、实现服务、编写插件等场景。
主要能力:Bun 直接执行 TypeScript 源码,开发与生产均无编译步骤,tsc 仅作类型检查(tsc --noEmit)。技术栈包括 Fastify 5.x、TypeScript、pino-pretty 日志、@fastify/env 环境变量校验、@fastify/cors、fastify-plugin。
使用方式:用 asdf 管理 Bun(asdf plugin add bun;asdf set bun latest;asdf install),生成 .tool-versions 固定版本。常用命令:bun run dev(bun --watch src/index.ts)、bun run typecheck(tsc --noEmit)、bun run start(bun run src/index.ts)、bun test。依赖统一用 bun add / bun add -d / bun remove 管理,提交 bun.lock。配置一律通过 fastify.config 读取,不直接用 process.env;插件注册顺序为 env、services、routes,index.ts 中访问配置前需 await server.ready()。项目结构含 plugins、routes、services、lib、app.ts、index.ts。代码质量采用 oxlint + oxfmt,脚本约定 dev、start、typecheck、lint、format、format:check、test。
限制:资料未提供具体版本号以外的性能数据、收费信息或部署平台细节;响应格式约定、认证方案、Swagger/OpenAPI、MCP 集成等细节需参考其列出的参考文件(setup-guide.md、patterns.md、authentication.md、api-design.md、mcp-integration.md、gotchas.md)。