import { deleteTemplate } from '../../utils/templates'

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

  if (!id) {
    throw createError({
      statusCode: 400,
      message: 'ID requerido'
    })
  }

  const success = await deleteTemplate(id)

  if (!success) {
    throw createError({
      statusCode: 404,
      message: 'Template no encontrado'
    })
  }

  return { success: true }
})
