refactor(board): atomic delete + query limit + composable cleanup
Delete uses findOneAndDelete with author match (no TOCTOU window); existence check only runs on miss to distinguish 403 vs 404. Posts list capped at 200. Drop unused resolveTagChannel and refreshParams; route slack URL building through the composable's slackUrl helper.
This commit is contained in:
parent
d1a1484daf
commit
28040f44f4
7 changed files with 30 additions and 54 deletions
|
|
@ -1,7 +1,3 @@
|
|||
/**
|
||||
* Board Posts Composable
|
||||
* Shared state + CRUD for board posts.
|
||||
*/
|
||||
export function useBoardPosts() {
|
||||
const posts = useState('board.posts', () => [])
|
||||
const loading = useState('board.loading', () => false)
|
||||
|
|
@ -17,29 +13,29 @@ export function useBoardPosts() {
|
|||
}
|
||||
}
|
||||
|
||||
async function createPost(body, refreshParams = {}) {
|
||||
async function createPost(body) {
|
||||
const created = await $fetch('/api/board/posts', {
|
||||
method: 'POST',
|
||||
body,
|
||||
})
|
||||
await fetchPosts(refreshParams)
|
||||
await fetchPosts()
|
||||
return created
|
||||
}
|
||||
|
||||
async function updatePost(id, body, refreshParams = {}) {
|
||||
async function updatePost(id, body) {
|
||||
const updated = await $fetch(`/api/board/posts/${id}`, {
|
||||
method: 'PATCH',
|
||||
body,
|
||||
})
|
||||
await fetchPosts(refreshParams)
|
||||
await fetchPosts()
|
||||
return updated
|
||||
}
|
||||
|
||||
async function deletePost(id, refreshParams = {}) {
|
||||
async function deletePost(id) {
|
||||
const result = await $fetch(`/api/board/posts/${id}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
await fetchPosts(refreshParams)
|
||||
await fetchPosts()
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue