@replyke/express
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
30 lines (29 loc) • 978 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const models_1 = require("../../../models");
exports.default = async (req, res) => {
try {
const { userId } = req.params;
const projectId = req.project.id;
if (!userId || typeof userId !== "string") {
res.status(400).json({
error: "Missing or invalid userId in request parameters",
code: "user/invalid-user-id",
});
return;
}
// Query the Follows table for followers count
const count = await models_1.Follow.count({
where: { projectId, followerId: userId },
});
res.status(200).json({ count });
}
catch (err) {
console.error("Error fetching following count: ", err);
res.status(500).json({
error: "Internal server error",
code: "user/server-error",
details: err.message,
});
}
};