Skip to content

Open source file-system and knowledge based agent template. Build AI agents that stay up to date with your knowledge base

381 B
Raw Blame
import type { H3Event } from 'h3'

export async function requireAdmin(event: H3Event) {
  const { user } = await requireUserSession(event)
  if (user.role !== 'admin') {
    throw createError({ statusCode: 403, message: 'Admin access required', data: { why: 'This endpoint requires the admin role', fix: 'Contact an administrator to be granted access' } })
  }
  return { user }
}