31 lines
779 B
TypeScript
31 lines
779 B
TypeScript
import User from "../../models/User";
|
|
import AppError from "../../errors/AppError";
|
|
import Queue from "../../models/Queue";
|
|
import Position from "../../models/Position";
|
|
|
|
const ShowUserService = async (id: string | number): Promise<User> => {
|
|
const user = await User.findByPk(id, {
|
|
attributes: [
|
|
"name",
|
|
"id",
|
|
"email",
|
|
"profile",
|
|
"positionId",
|
|
"tokenVersion",
|
|
"transferToOtherQueues"
|
|
],
|
|
include: [
|
|
{ model: Queue, as: "queues", attributes: ["id", "name", "color"] },
|
|
{ model: Position, attributes: ["id", "name"] }
|
|
],
|
|
order: [[{ model: Queue, as: "queues" }, "name", "asc"]]
|
|
});
|
|
if (!user) {
|
|
throw new AppError("ERR_NO_USER_FOUND", 404);
|
|
}
|
|
|
|
return user;
|
|
};
|
|
|
|
export default ShowUserService;
|