pitfalls-express-api
使用正確的 REST 模式建構 Express API
Express API 開發經常導致路由不一致、狀態碼錯誤以及儲存邏輯緊密耦合。此技能提供經過驗證的 RESTful 路由、HTTP 狀態碼、儲存介面和背景工作管理模式。
스킬 ZIP 다운로드
Claude에서 업로드
설정 → 기능 → 스킬 → 스킬 업로드로 이동
토글을 켜고 사용 시작
테스트해 보기
"pitfalls-express-api" 사용 중입니다. Create a users API with CRUD operations
예상 결과:
- GET /api/users - Returns list of users (200)
- GET /api/users/:id - Returns single user (200) or not found (404)
- POST /api/admin/users - Creates user (201) with validation
- PATCH /api/admin/users/:id - Updates user (200) or not found (404)
- DELETE /api/admin/users/:id - Deletes user (204)
"pitfalls-express-api" 사용 중입니다. How should I handle status codes for a PATCH endpoint?
예상 결과:
- 200 OK on successful update with modified data
- 404 Not Found when resource does not exist
- 400 Bad Request when validation fails
- 204 No Content is not recommended for PATCH as the response typically includes updated data
"pitfalls-express-api" 사용 중입니다. Create a storage interface for products
예상 결과:
- interface IStorage with getProducts, getProduct, createProduct, updateProduct, deleteProduct methods
- DbStorage class implementing PostgreSQL backend
- MemStorage class implementing in-memory storage for testing
- Generic CRUD operations using TypeScript types
보안 감사
안전This is a pure documentation skill containing only TypeScript code examples in markdown. The static scanner triggered on markdown code block backticks and function naming conventions that have no security implications. All 41 findings are false positives caused by the scanner misinterpreting documentation syntax as code patterns.
위험 요인
🌐 네트워크 접근 (1)
📁 파일 시스템 액세스 (1)
⚙️ 외부 명령어 (5)
품질 점수
만들 수 있는 것
建構一致的 API
在建立新的 Express 路由和端點時,應用 REST 慣例和狀態碼模式。
審查 API 實作
驗證現有的 Express API 是否遵循路由結構和錯誤處理的最佳實踐。
設計儲存介面
建立抽象的儲存層,支援不同的後端並便於測試。
이 프롬프트를 사용해 보세요
Create a new Express route for [resource] following REST conventions. Include validation, proper status codes, and error handling.
Review these Express routes for REST compliance, correct status codes, and missing validation. Point out any anti-patterns.
Design a TypeScript storage interface for [entity] with create, read, update, delete operations. Include an in-memory implementation for testing.
Add a background job to my Express app that runs every 5 minutes. Include proper cleanup on process exit and overlap protection.
모범 사례
- 使用適當的驗證中介軟體分離公開路由和管理員路由
- 在處理之前始終使用中介軟體驗證請求主體
- 定義儲存介面以抽象資料庫實作細節
- 在程序終止訊號時清理背景工作間隔
피하기
- 在類似操作中使用不一致的 HTTP 狀態碼
- 在建立和更新端點上跳過輸入驗證
- 直接在路由處理器中實作儲存邏輯
- 在沒有保護的情況下執行重疊的背景工作