refactor: professional code quality audit
- Fix all TypeScript compilation errors (0 errors in src/) - Add try/catch error handling to ALL API routes (38 handlers) - Fix empty catch blocks (api-auth.ts now logs warnings) - Add aria-labels to all icon-only buttons (WCAG 2.1 AA) - Fix Prisma type mismatches (OR filter, Person.companyId, Estimate.projectId, Ticket.createdAt) - Fix webhook PATCH route (moved to [id]/route.ts) - Fix mobile-bottom-nav type safety - Fix KB route where-clause type - Fix test-mail banner null vs undefined - Fix task comment fetch: add cancellation + error toast - ESLint: 0 errors, 0 warnings - 175 files, 24.741 lines of code
This commit is contained in:
1 parent
969202764a
commit
fa8dd46571
175 files changed
+24741
-2
No files matched your search
Executable
+55
@@ -0,0 +1,55 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { exec } from 'child_process'
|
||||
import { promisify } from 'util'
|
||||
|
||||
const execAsync = promisify(exec)
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
export const maxDuration = 60
|
||||
|
||||
// POST /api/aos/seed — reseed the database (destructive, dev only)
|
||||
export async function POST() {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
return NextResponse.json({ error: 'not in production' }, { status: 403 })
|
||||
}
|
||||
try {
|
||||
// wipe via prisma (SQLite TRUNCATE not supported, use deleteMany per model in order)
|
||||
const { db } = await import('@/lib/db')
|
||||
await db.dunningRun.deleteMany()
|
||||
await db.vatReturn.deleteMany()
|
||||
await db.bankTransaction.deleteMany()
|
||||
await db.webhook.deleteMany()
|
||||
await db.apiToken.deleteMany()
|
||||
await db.portalApproval.deleteMany()
|
||||
await db.article.deleteMany()
|
||||
await db.taskComment.deleteMany()
|
||||
await db.estimateLine.deleteMany()
|
||||
await db.estimate.deleteMany()
|
||||
await db.ticketMessage.deleteMany()
|
||||
await db.ticket.deleteMany()
|
||||
await db.expense.deleteMany()
|
||||
await db.contract.deleteMany()
|
||||
await db.invoiceLine.deleteMany()
|
||||
await db.invoice.deleteMany()
|
||||
await db.asset.deleteMany()
|
||||
await db.licenseActivation.deleteMany()
|
||||
await db.license.deleteMany()
|
||||
await db.timeEntry.deleteMany()
|
||||
await db.task.deleteMany()
|
||||
await db.project.deleteMany()
|
||||
await db.lead.deleteMany()
|
||||
await db.deal.deleteMany()
|
||||
await db.person.deleteMany()
|
||||
await db.company.deleteMany()
|
||||
await db.auditLog.deleteMany()
|
||||
await db.setting.deleteMany()
|
||||
await db.module.deleteMany()
|
||||
await db.user.deleteMany()
|
||||
|
||||
await execAsync('bun run src/lib/seed.ts', { cwd: process.cwd() })
|
||||
return NextResponse.json({ ok: true })
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : 'seed failed'
|
||||
return NextResponse.json({ error: msg }, { status: 500 })
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user