b7b6076846
- Add favicon_url column to nodes table via database migration - Create favicon upload endpoint with media handling - Implement favicon upload UI in admin panel with preview - Add favicon removal functionality in admin settings - Create BlurredVideo component for improved video rendering - Update PostCard to use new BlurredVideo component - Update node schema to include favicon_url field - Add favicon upload state management and error handling - Enables customization of browser tab icon for node branding
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { db } from '@/db';
|
|
import { nodes } from '@/db';
|
|
import { eq } from 'drizzle-orm';
|
|
import { requireAdmin } from '@/lib/auth/admin';
|
|
|
|
export async function PATCH(req: NextRequest) {
|
|
try {
|
|
await requireAdmin();
|
|
const data = await req.json();
|
|
|
|
const domain = process.env.NEXT_PUBLIC_NODE_DOMAIN || 'localhost:3000';
|
|
|
|
let node = await db.query.nodes.findFirst({
|
|
where: eq(nodes.domain, domain),
|
|
});
|
|
|
|
if (!node) {
|
|
[node] = await db.insert(nodes).values({
|
|
domain,
|
|
name: data.name || process.env.NEXT_PUBLIC_NODE_NAME || 'Synapsis Node',
|
|
description: data.description,
|
|
longDescription: data.longDescription,
|
|
rules: data.rules,
|
|
bannerUrl: data.bannerUrl,
|
|
logoUrl: data.logoUrl,
|
|
faviconUrl: data.faviconUrl,
|
|
accentColor: data.accentColor,
|
|
isNsfw: data.isNsfw ?? false,
|
|
}).returning();
|
|
} else {
|
|
[node] = await db.update(nodes)
|
|
.set({
|
|
name: data.name,
|
|
description: data.description,
|
|
longDescription: data.longDescription,
|
|
rules: data.rules,
|
|
bannerUrl: data.bannerUrl,
|
|
logoUrl: data.logoUrl,
|
|
faviconUrl: data.faviconUrl,
|
|
accentColor: data.accentColor,
|
|
isNsfw: data.isNsfw ?? node.isNsfw,
|
|
updatedAt: new Date(),
|
|
})
|
|
.where(eq(nodes.id, node.id))
|
|
.returning();
|
|
}
|
|
|
|
return NextResponse.json({ node });
|
|
} catch (error) {
|
|
console.error('Update node settings error:', error);
|
|
return NextResponse.json({ error: 'Failed to update settings' }, { status: 500 });
|
|
}
|
|
}
|