feat(wiki): add admin wiki management API routes
This commit is contained in:
parent
3797ff7925
commit
e4f2efd6d0
5 changed files with 375 additions and 0 deletions
24
server/api/admin/wiki/index.get.js
Normal file
24
server/api/admin/wiki/index.get.js
Normal 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
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue