import TagSuggestion from '../../models/tagSuggestion.js'
import { tagSuggestionSchema } from '../../utils/schemas.js'

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

  const member = await requireAuth(event)
  const body = await validateBody(event, tagSuggestionSchema)

  await TagSuggestion.create({
    label: body.label,
    pool: body.pool,
    suggestedBy: member._id
  })

  return { success: true }
})
