Spaces:
Running
Running
File size: 844 Bytes
f25edb3 bdc8b77 f25edb3 44bc950 f25edb3 bdc8b77 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import { Request, Response } from "express";
import { z } from "zod";
import { getFullUser, getUserById } from "../repository/user-repository";
const UserParamsSchema = z.object({
id: z.uuid(),
});
export async function getUserByIdHandler(req: Request, res: Response) {
const params = UserParamsSchema.safeParse(req.params);
if (!params.success) {
return res.status(400).json({ error: "Invalid parameters" });
}
const data = await getUserById(params.data.id);
return res.json({ success: true, data });
}
export async function getFullUserById(req: Request, res: Response) {
const params = UserParamsSchema.safeParse(req.params);
if (!params.success) {
return res.status(400).json({ error: "Invalid parameters" });
}
const data = await getFullUser(params.data.id);
return res.json({ success: true, data });
}
|