2024-03-06 19:43:09 +00:00

17 lines
433 B
JavaScript
Executable File

import { UserFollow } from "@db_models"
export default {
method: "GET",
route: "/user/:user_id",
middlewares: ["withAuthentication"],
fn: async (req, res) => {
const isFollowed = await UserFollow.findOne({
user_id: req.user._id.toString(),
to: req.params.user_id,
}).catch(() => false)
return res.json({
isFollowed: Boolean(isFollowed),
})
}
}