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

View File

@@ -0,0 +1,57 @@
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';
import { withAuth } from '@/lib/auth';
// GET - Aktif canlı yayın bilgisini getir
export async function GET() {
try {
const liveStream = await prisma.liveStream.findFirst({
where: { active: true },
});
return NextResponse.json(liveStream || { active: false, url: '', title: '' });
} catch (error) {
console.error('Live stream fetch error:', error);
return NextResponse.json(
{ error: 'Canlı yayın bilgisi alınırken hata oluştu' },
{ status: 500 }
);
}
}
// POST - Canlı yayın ayarlarını güncelle (Auth gerekli)
export async function POST(request: NextRequest) {
return withAuth(request, async () => {
try {
const data = await request.json();
// Önce tüm canlı yayınları pasif yap
await prisma.liveStream.updateMany({
data: { active: false },
});
// Yeni ayarları oluştur veya güncelle
const liveStream = await prisma.liveStream.upsert({
where: { id: data.id || 0 },
update: {
url: data.url,
active: data.active,
title: data.title,
},
create: {
url: data.url,
active: data.active,
title: data.title,
},
});
return NextResponse.json(liveStream);
} catch (error) {
console.error('Live stream update error:', error);
return NextResponse.json(
{ error: 'Canlı yayın güncellenirken hata oluştu' },
{ status: 500 }
);
}
});
}