mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
29 lines
693 B
JavaScript
Executable File
29 lines
693 B
JavaScript
Executable File
import { Schematized } from "@lib"
|
|
import { ToogleLike } from "../services"
|
|
|
|
export default {
|
|
method: "POST",
|
|
route: "/:post_id/toggle_like",
|
|
middlewares: ["withAuthentication"],
|
|
fn: Schematized({
|
|
select: ["to"],
|
|
}, async (req, res) => {
|
|
const post = await ToogleLike({
|
|
user_id: req.user._id.toString(),
|
|
post_id: req.params.post_id,
|
|
to: req.selection.to,
|
|
}).catch((err) => {
|
|
res.status(400).json({
|
|
error: err.message
|
|
})
|
|
return false
|
|
})
|
|
|
|
if (!post) return
|
|
|
|
return res.json({
|
|
success: true,
|
|
post
|
|
})
|
|
})
|
|
} |