Spaces:
Running
Running
Download src/api/controller/user-controller.ts from risenetup/chess-monolith: direct link, hf CLI and curl.
- Browser
- Download file 844 Bytes
-
https://huggingface.co/spaces/risenetup/chess-monolith/resolve/main/src/api/controller/user-controller.ts
- Command line
-
hf download hf://spaces/risenetup/chess-monolith/src/api/controller/user-controller.ts
-
curl -L -o user-controller.ts https://huggingface.co/spaces/risenetup/chess-monolith/resolve/main/src/api/controller/user-controller.ts
844 Bytes
| 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 }); | |
| } | |