import PreRegistration from '../../../models/preRegistration.js'
import { connectDB } from '../../../utils/mongoose.js'

export default defineEventHandler(async (event) => {
  await requireAdmin(event)
  await connectDB()

  const preRegistrants = await PreRegistration.find()
    .sort({ createdAt: -1 })
    .lean()

  return preRegistrants
})
