5 PRD gaps fixed: 1. Zod validation on all API inputs (§5.2) — 26 files, 27 safeParse 2. Rate limiting on public endpoints (§5.6) — 6 scopes, 7 endpoints 3. Custom fields JSONB with schema (§5.5) — 2 models, 10 seed defs 4. CSP + security headers (§5.6) — 7 headers via next.config.ts 5. ESLint module boundary rule (§5.4) — no-restricted-imports 0 TS errors, ESLint clean.
26 lines
674 B
TypeScript
Executable File
26 lines
674 B
TypeScript
Executable File
import { NextResponse } from 'next/server'
|
|
import { db } from '@/lib/db'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
// GET /api/health — system health check
|
|
export async function GET() {
|
|
try {
|
|
const companyCount = await db.company.count()
|
|
|
|
return NextResponse.json({
|
|
status: 'ok',
|
|
timestamp: new Date().toISOString(),
|
|
version: '1.0.0',
|
|
database: { connected: true, companyCount },
|
|
uptime: process.uptime ? `${Math.round(process.uptime())}s` : 'n/a',
|
|
})
|
|
} catch {
|
|
return NextResponse.json({
|
|
status: 'error',
|
|
timestamp: new Date().toISOString(),
|
|
database: { connected: false },
|
|
}, { status: 503 })
|
|
}
|
|
}
|