API Key System: - Add TpmjsApiKey, ApiUsageRecord, ApiUsageSummary models to schema - Create API key utilities (generate, hash, mask with tpmjs_sk_ prefix) - Implement dual auth middleware (session + API key) - Add rate limiting with Vercel KV - Create CRUD endpoints for API key management - Add usage tracking and analytics endpoint - Build API key management UI in dashboard - Build usage dashboard with charts Route Protection: - Require auth for MCP endpoints (mcp:execute scope) - Require auth for agent chat (agent:chat scope) - Require auth for bridge connections (bridge:connect scope) Documentation Updates: - Update all curl/fetch examples with Authorization header - Document API key format, scopes, and rate limits - Update PRD-MCP-BRIDGE.md, MCP-AGGREGATOR-DESIGN.md - Update API docs page with auth requirements - Update HOW_TO_PUBLISH_A_TOOL.md |
||
|---|---|---|
| .. | ||
| prisma | ||
| scripts | ||
| src | ||
| .env.example | ||
| .gitignore | ||
| 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.