项目文件夹

文件
wehub-resource-sync bb5c75ce05
Component Security Validation / Security Audit (push) Has been cancelled
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:38:58 +08:00

1 行
2.5 KiB
JSON

{"content": "---\nname: api-patterns\ndescription: API design principles and decision-making. REST vs GraphQL vs tRPC selection, response formats, versioning, pagination.\nallowed-tools: Read, Write, Edit, Glob, Grep\n---\n\n# API Patterns\n\n> API design principles and decision-making for 2025.\n> **Learn to THINK, not copy fixed patterns.**\n\n## 🎯 Selective Reading Rule\n\n**Read ONLY files relevant to the request!** Check the content map, find what you need.\n\n---\n\n## 📑 Content Map\n\n| File | Description | When to Read |\n|------|-------------|--------------|\n| `api-style.md` | REST vs GraphQL vs tRPC decision tree | Choosing API type |\n| `rest.md` | Resource naming, HTTP methods, status codes | Designing REST API |\n| `response.md` | Envelope pattern, error format, pagination | Response structure |\n| `graphql.md` | Schema design, when to use, security | Considering GraphQL |\n| `trpc.md` | TypeScript monorepo, type safety | TS fullstack projects |\n| `versioning.md` | URI/Header/Query versioning | API evolution planning |\n| `auth.md` | JWT, OAuth, Passkey, API Keys | Auth pattern selection |\n| `rate-limiting.md` | Token bucket, sliding window | API protection |\n| `documentation.md` | OpenAPI/Swagger best practices | Documentation |\n| `security-testing.md` | OWASP API Top 10, auth/authz testing | Security audits |\n\n---\n\n## 🔗 Related Skills\n\n| Need | Skill |\n|------|-------|\n| API implementation | `@[skills/backend-development]` |\n| Data structure | `@[skills/database-design]` |\n| Security details | `@[skills/security-hardening]` |\n\n---\n\n## ✅ Decision Checklist\n\nBefore designing an API:\n\n- [ ] **Asked user about API consumers?**\n- [ ] **Chosen API style for THIS context?** (REST/GraphQL/tRPC)\n- [ ] **Defined consistent response format?**\n- [ ] **Planned versioning strategy?**\n- [ ] **Considered authentication needs?**\n- [ ] **Planned rate limiting?**\n- [ ] **Documentation approach defined?**\n\n---\n\n## ❌ Anti-Patterns\n\n**DON'T:**\n- Default to REST for everything\n- Use verbs in REST endpoints (/getUsers)\n- Return inconsistent response formats\n- Expose internal errors to clients\n- Skip rate limiting\n\n**DO:**\n- Choose API style based on context\n- Ask about client requirements\n- Document thoroughly\n- Use appropriate status codes\n\n---\n\n## Script\n\n| Script | Purpose | Command |\n|--------|---------|---------|\n| `scripts/api_validator.py` | API endpoint validation | `python scripts/api_validator.py <project_path>` |\n\n"}