import BoardChannel from '../../../models/boardChannel.js'
import { requireAdmin } from '../../../utils/auth.js'

export default defineEventHandler(async (event) => {
  await requireAdmin(event)
  const id = getRouterParam(event, 'id')

  const channel = await BoardChannel.findByIdAndDelete(id)
  if (!channel) {
    throw createError({ statusCode: 404, statusMessage: 'Channel not found' })
  }

  return { success: true }
})
