UNPKG

@replyke/express

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

46 lines (45 loc) 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const models_1 = require("../../../models"); exports.default = async (req, res) => { try { const { userId } = req.params; if (!userId || typeof userId !== "string") { res.status(400).json({ error: "Missing or invalid userId in request parameters", code: "user/invalid-user-id", }); return; } // Perform the query on the Entity model with pagination, sorting, and filtering const user = await models_1.User.findByPk(userId, { attributes: { exclude: [ "hash", "salt", "email", "isVerified", "isActive", "lastActive", "secureMetadata", ], }, }); if (!user) { res.status(404).json({ error: "User not found", code: "user/not-found", }); return; } res.status(200).json(user.toJSON()); } catch (err) { console.error("Error fetching user: ", err); res.status(500).json({ error: "Internal server error", code: "user/server-error", details: err.message, }); } };