feat(wiki): add admin wiki management API routes

This commit is contained in:
Jennie Robinson Faber 2026-04-09 22:36:44 +01:00
parent 3797ff7925
commit e4f2efd6d0
5 changed files with 375 additions and 0 deletions

View file

@ -0,0 +1,24 @@
import WikiArticle from '../../../models/wikiArticle.js'
import { connectDB } from '../../../utils/mongoose.js'
export default defineEventHandler(async (event) => {
await requireAdmin(event)
await connectDB()
const { collection, search } = getQuery(event)
const filter = {}
if (collection) {
filter.collection = collection
}
if (search) {
filter.title = { $regex: search, $options: 'i' }
}
const articles = await WikiArticle.find(filter)
.select('collection title tags url outlineId publishedAt')
.sort({ collection: 1, title: 1 })
.lean()
return articles
})