yo-next-auth/app/api/admin/route.ts

10 lines
300 B
TypeScript

import { NextResponse } from 'next/server'
import { currentRole } from '@/lib/auth'
import { UserRole } from '@prisma/client'
export async function GET () {
const role = await currentRole()
const status: number = role === UserRole.ADMIN ? 200 : 403
return new NextResponse(null, { status })
}