2026-08-26 16:20:55 +08:00

32 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ADR-001: 使用 Express 5 作为后端框架Node.js
## Status: Accepted (2026-08-26)
## Background
「备考中枢」是个人单用户公务员备考数据中枢,需要一组 REST API 对接 Vue3 前端完成题库录入、刷题、错题本、模考、申论、备考计划、统计聚合。数据量级为个人1-2 万题/年),无多租户、无高并发、无复杂分布式。用户已拍板后端用 Express。
## Decision
采用 **Express 5.xNode.js 24 LTSESM全 TypeScript** 作为后端框架。版本锚定:
- Express `5.2.x`(已是 npm `latest` 默认线,要求 Node ≥ 18
- Node.js `24.x`Active LTS
选型理由:
1. 技术矩阵定位Express 在 MVP 后端框架对比中「MVP 速度 5/5、性能 3/5」正对本项目「简单 CRUD + 全栈 JS」场景对照 `mvp-stack.md`)。
2. 生态成熟129M 周下载、文档完善、中间件丰富、任意 Node 开发可秒上手,学习成本最低。
3. 与前端同用 TS/JS全栈统一语言与类型系统`packages/shared` 可共享领域类型。
4. 单用户低并发下性能完全够用(瓶颈在 JSON 数据层,非框架本身)。
## Consequences
- 正面:开发速度快、团队熟悉、生态成熟、部署极简(一个 Node 容器)。
- 负面Express 5 无内置依赖注入、中间件顺序随代码增长需谨慎;性能不承诺高并发(个人场景无碍)。
- 权衡Express 5 是 npm 默认线新项目直接用v4 已入 MaintenanceEOL ≥ 2026-10-01不采用。
## Related ADRs
- ADR-003本地 JSON 数据层)
- ADR-004全 TS strict + zod
- ADR-005monorepo 布局)
- ADR-006垂直切片 + 单一契约源)