API Endpoints (Phase 2 - Part 2):
1. Manual Health Check Endpoint
- POST /api/tools/[...slug]
- Added POST handler to existing tool detail route
- Extracts slug parsing into shared parseSlug() helper
- 5-minute rate limit per tool
- Returns full health check results
- Validates that export name is provided (can't check whole package)
2. Health Filtering in /api/tools
- Add query params: ?importHealth=HEALTHY|BROKEN|UNKNOWN
- Add query params: ?executionHealth=HEALTHY|BROKEN|UNKNOWN
- Add shorthand: ?broken=true (at least one health check failed)
- Health filters applied as AND conditions with search/category filters
- Refactored to reduce complexity:
- Extract buildHealthFilters() helper
- Extract buildPackageFilter() helper
- Extract buildWhereClause() helper
3. Code Quality Improvements
- Extract parseSlug() helper to reduce duplication (DRY)
- Remove useless else clauses (biome lint fix)
- Reduce cognitive complexity (GET: 16->8, POST: simplified)
RESTful Design:
- GET /api/tools/@tpmjs/hello/hello -> Fetch tool data
- POST /api/tools/@tpmjs/hello/hello -> Trigger health check
Query Examples:
- /api/tools?broken=true (all broken tools)
- /api/tools?importHealth=HEALTHY&executionHealth=HEALTHY (fully healthy)
- /api/tools?q=text&broken=true (search "text" in broken tools)
Rate Limiting:
- Manual recheck cooldown: 5 minutes per tool
- Returns 429 with retryAfter seconds on rate limit
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| playground | ||
| railway-executor | ||
| web | ||