import Tag from '../../models/tag.js'

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

  const query = getQuery(event)
  const filter = { active: true }

  if (query.pool) {
    filter.pool = query.pool
  }

  const tags = await Tag.find(filter).sort({ label: 1 }).lean()

  return { tags }
})
