Switch navbar to #001321, admin can update logo/favicon, logo links home
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { requireRole } from '@/lib/auth';
|
||||
import { db } from '@/lib/db';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const key = request.nextUrl.searchParams.get('key');
|
||||
if (!key) {
|
||||
return NextResponse.json({ error: 'Missing key' }, { status: 400 });
|
||||
}
|
||||
|
||||
const { rows } = await db.query('SELECT value FROM config WHERE key = $1', [key]);
|
||||
return NextResponse.json({ data: rows[0]?.value || null });
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
await requireRole('admin');
|
||||
const body = await request.json();
|
||||
const { key, value } = body;
|
||||
|
||||
if (!key || typeof value !== 'string') {
|
||||
return NextResponse.json({ error: 'Missing key or value' }, { status: 400 });
|
||||
}
|
||||
|
||||
await db.query(
|
||||
`INSERT INTO config (key, value) VALUES ($1, $2)
|
||||
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`,
|
||||
[key, value]
|
||||
);
|
||||
|
||||
return NextResponse.json({ ok: true });
|
||||
} catch (err: any) {
|
||||
return NextResponse.json({ error: err.message || 'Failed to save asset' }, { status: 401 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user