- migrate from SQLite to PostgreSQL with Drizzle ORM - implement comprehensive AdminLayout with expandable sidebar navigation - create professional dashboard with real-time charts and metrics - add advanced monitoring, reporting, and export functionality - fix menu alignment and remove non-existent pages - eliminate duplicate headers and improve UI consistency - add Tailwind CSS v3 for professional styling - expand database schema from 6 to 15 tables - implement role-based access control and API key management - create comprehensive settings, monitoring, and system info pages
37 lines
998 B
TypeScript
37 lines
998 B
TypeScript
import type { NextApiRequest, NextApiResponse } from 'next'
|
|
import { db, schema } from '../../../../lib/db/connection'
|
|
import { eq } from 'drizzle-orm'
|
|
|
|
export default async function handler(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse
|
|
) {
|
|
if (req.method !== 'PATCH') {
|
|
return res.status(405).json({ error: 'Method not allowed' })
|
|
}
|
|
|
|
const { id } = req.query
|
|
const { status, risk_level, rejection_reason } = req.body
|
|
|
|
if (!id || !status) {
|
|
return res.status(400).json({ error: 'ID and status are required' })
|
|
}
|
|
|
|
try {
|
|
await db
|
|
.update(schema.sources)
|
|
.set({
|
|
status: status,
|
|
riskLevel: risk_level || 0,
|
|
rejectionReason: rejection_reason || null,
|
|
updatedAt: new Date()
|
|
})
|
|
.where(eq(schema.sources.id, parseInt(id as string)))
|
|
|
|
return res.status(200).json({ success: true })
|
|
|
|
} catch (error) {
|
|
console.error('Database error:', error)
|
|
return res.status(500).json({ error: 'Internal server error' })
|
|
}
|
|
} |