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

17 lines
447 B
JavaScript
Executable File

import { UserFollow } from "@shared-classes/DbModels"
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),
})
}
}