Add comprehensive health monitoring for TPMJS tools that tracks both import and execution health via Railway executor service. ## Database Schema - Add HealthStatus enum (UNKNOWN, HEALTHY, BROKEN) - Add HealthCheckType enum (IMPORT, EXECUTION, FULL) - Add health fields to Tool model: - importHealth: tracks if tool can be loaded - executionHealth: tracks if tool can execute - lastHealthCheck: timestamp of last check - healthCheckError: stores error message - Add HealthCheck audit table for full history ## Core Service Create health-check-service.ts with 5 functions: 1. checkImportHealth() - Tests tool loading via /load-and-describe 2. checkExecutionHealth() - Tests execution via /execute-tool 3. generateTestParameters() - Creates minimal test params by type 4. performHealthCheck() - Full check with database updates 5. performBatchHealthCheck() - Processes tools in batches Features: - 30-second timeout per check - Skips execution if import fails - Batch processing (5 concurrent, 1s delays) - Full audit trail in HealthCheck table ## API Endpoints /api/sync/health-check (POST): - Daily cron job at 2am UTC - Checks all tools in database - Requires CRON_SECRET auth - Logs results to SyncLog table - Max duration: 5 minutes /api/tools/broken (GET): - Lists all tools with broken health status - Filters by importHealth='BROKEN' OR executionHealth='BROKEN' - Includes package metadata - Orders by lastHealthCheck DESC ## Configuration - Add RAILWAY_EXECUTOR_URL to env.ts - Add daily cron job to vercel.json - Use db:push for schema changes (existing production data) Next: Manual trigger endpoint + health filtering + UI components 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| prisma | ||
| src | ||
| .env.example | ||
| check-tool.js | ||
| check-tool.mjs | ||
| package.json | ||
| README.md | ||
| sync-single-tool.mjs | ||
| test-query.mjs | ||
| tsconfig.json | ||
@tpmjs/db
Database package for TPMJS NPM Registry. Provides Prisma ORM setup and database client for storing tool metadata.
Setup
1. Create Neon Database
- Go to https://neon.tech/
- Create a new project
- Copy the connection string
2. Configure Environment
cp .env.example .env
# Edit .env and add your DATABASE_URL
3. Run Migrations
pnpm db:migrate
pnpm db:seed
Usage
import { prisma } from '@tpmjs/db';
// Query tools
const tools = await prisma.tool.findMany({
where: {
category: 'web-scraping',
isOfficial: true,
},
orderBy: {
qualityScore: 'desc',
},
take: 10,
});
// Update sync checkpoint
await prisma.syncCheckpoint.update({
where: { source: 'changes-feed' },
data: {
checkpoint: {
sequence: '12345',
lastProcessed: new Date().toISOString(),
},
},
});
Scripts
pnpm db:generate- Generate Prisma clientpnpm db:push- Push schema to database (for development)pnpm db:migrate- Create and run migrations (for production)pnpm db:studio- Open Prisma Studio GUIpnpm db:seed- Seed initial data
Schema
Tool
Stores NPM packages with TPMJS metadata from their package.json.
SyncCheckpoint
Tracks progress of sync workers (changes feed, keyword search, metrics).
SyncLog
Audit trail of all sync operations.