2024-03-05 10:20:36 +00:00

26 lines
572 B
JavaScript
Executable File

import { DeletePost } from "../services"
export default {
method: "DELETE",
route: "/:post_id",
middlewares: ["withAuthentication"],
fn: async (req, res) => {
const post = await DeletePost({
post_id: req.params.post_id,
by_user_id: req.user._id.toString(),
}).catch((err) => {
res.status(400).json({
error: err.message
})
return false
})
if (!post) return
return res.json({
success: true,
post
})
}
}