Files

33 lines
970 B
TypeScript
Raw Permalink Normal View History

2025-09-07 22:57:43 +00:00
import { NextResponse } from 'next/server';
import { PrismaClient } from '@/app/generated/prisma';
2025-09-10 04:31:53 +00:00
// 모든 Handle을 단순 목록으로 반환합니다.
// 관리자 UI 호환을 위해 필드 형태를 맞춥니다.
2025-09-07 22:57:43 +00:00
export async function GET() {
const prisma = new PrismaClient();
try {
2025-09-10 04:31:53 +00:00
const handles = await prisma.handle.findMany({
orderBy: { handle: 'asc' },
select: { id: true, handle: true, avatar: true, costPerView: true },
2025-09-07 22:57:43 +00:00
});
2025-09-10 04:31:53 +00:00
const nowIso = new Date().toISOString();
const items = handles.map(h => ({
id: h.id,
email: '',
handle: h.handle,
isApproved: true,
createtime: nowIso,
icon: h.avatar,
costPerView: Number(h.costPerView ?? 0),
}));
return NextResponse.json({ items });
2025-09-07 22:57:43 +00:00
} catch (e) {
console.error('admin user_handles 오류:', e);
return NextResponse.json({ error: '조회 실패' }, { status: 500 });
} finally {
await prisma.$disconnect();
}
}