Files
ef_front/app/api/channel/mycode/route.ts

34 lines
962 B
TypeScript
Raw Permalink Normal View History

2025-09-09 00:15:08 +00:00
export const runtime = 'nodejs'
import { NextResponse } from 'next/server'
import { auth } from '@/auth'
import { PrismaClient } from '@/app/generated/prisma'
export async function GET() {
console.log('mycode 요청')
const session = await auth()
if (!session) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}
const email = session.user?.email as string | undefined
if (!email) {
return NextResponse.json({ error: '세션 이메일을 찾을 수 없습니다' }, { status: 400 })
}
const prisma = new PrismaClient()
try {
const user = await prisma.user.findFirst({
where: { email },
select: { RegisgerCode: true },
})
return NextResponse.json({ registerCode: user?.RegisgerCode ?? null })
} catch (e) {
console.error('register_code 조회 오류:', e)
return NextResponse.json({ error: '조회 실패' }, { status: 500 })
} finally {
await prisma.$disconnect()
}
}