This commit is contained in:
Şahan Hasret
2025-11-21 17:46:30 +03:00
parent c0b7fb463e
commit 76c31274d5
46 changed files with 3675 additions and 1043 deletions

52
app/api/settings/route.ts Normal file
View File

@@ -0,0 +1,52 @@
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';
import { withAuth } from '@/lib/auth';
// GET - Site ayarlarını getir
export async function GET() {
try {
const settings = await prisma.siteSettings.findFirst({
where: { key: 'main' },
});
if (!settings) {
return NextResponse.json({ error: 'Ayarlar bulunamadı' }, { status: 404 });
}
return NextResponse.json(JSON.parse(settings.value));
} catch (error) {
console.error('Settings fetch error:', error);
return NextResponse.json(
{ error: 'Ayarlar alınırken hata oluştu' },
{ status: 500 }
);
}
}
// POST - Site ayarlarını güncelle (Auth gerekli)
export async function POST(request: NextRequest) {
return withAuth(request, async () => {
try {
const data = await request.json();
const settings = await prisma.siteSettings.upsert({
where: { key: 'main' },
update: {
value: JSON.stringify(data),
},
create: {
key: 'main',
value: JSON.stringify(data),
},
});
return NextResponse.json(JSON.parse(settings.value));
} catch (error) {
console.error('Settings update error:', error);
return NextResponse.json(
{ error: 'Ayarlar güncellenirken hata oluştu' },
{ status: 500 }
);
}
});
}