feat: add Tags API endpoints and validation schemas

- GET /api/tags — public, filterable by ?pool=craft|cooperative, active only, sorted by label
- POST /api/tags/suggest — auth-required, creates TagSuggestion doc
- Add tagSuggestionSchema and communityConnectionsUpdateSchema to schemas.js
- Extend memberProfileUpdateSchema with craftTags, craftTagsPrivacy, communityConnectionsPrivacy
This commit is contained in:
Jennie Robinson Faber 2026-04-05 16:15:29 +01:00
parent 18b8106405
commit 79d038c724
3 changed files with 56 additions and 1 deletions

View file

@ -0,0 +1,16 @@
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 }
})

View file

@ -0,0 +1,17 @@
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 }
})