import { getDb } from '../../utils/db.js'
import { requireAuth } from '../../utils/authHelpers.js'

export default defineEventHandler(async (event) => {
  requireAuth(event, { role: 'adminOrLeader' })
  const id = event.context.params?.id
  if (!id) throw createError({ statusCode: 400, message: 'id required' })
  const { run } = await getDb()
  await run('DELETE FROM pois WHERE id = ?', [id])
  setResponseStatus(event, 204)
  return null
})
