feat: board post + channel API routes
Implements Phase 2a of board classifieds redesign: - GET/POST /api/board/posts (list with tag/author filters, create) - PATCH/DELETE /api/board/posts/:id (author-only) - GET /api/board/channels (member) - POST /api/admin/board-channels (admin) - PATCH/DELETE /api/admin/board-channels/:id (admin) Adds board_post_created activity type.
This commit is contained in:
parent
8e5f4a2d7c
commit
6a440a846d
9 changed files with 218 additions and 0 deletions
24
server/api/board/posts.get.js
Normal file
24
server/api/board/posts.get.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import BoardPost from '../../models/boardPost.js'
|
||||
import { requireAuth } from '../../utils/auth.js'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const member = await requireAuth(event)
|
||||
|
||||
const query = getQuery(event)
|
||||
const dbQuery = {}
|
||||
|
||||
if (query.tag) {
|
||||
dbQuery.tags = query.tag
|
||||
}
|
||||
|
||||
if (query.author) {
|
||||
dbQuery.author = query.author === 'me' ? member._id : query.author
|
||||
}
|
||||
|
||||
const posts = await BoardPost.find(dbQuery)
|
||||
.sort({ createdAt: -1 })
|
||||
.populate('author', 'name avatar circle board.slackHandle')
|
||||
.lean()
|
||||
|
||||
return { posts }
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue