From 1ce7879ee85ea5bb5efaff3cf950e65513098d3c Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Sat, 25 Mar 2023 16:09:04 -0400 Subject: oapi: users progress --- src/api/routes/users/@me/index.ts | 41 ++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'src/api/routes/users/@me/index.ts') diff --git a/src/api/routes/users/@me/index.ts b/src/api/routes/users/@me/index.ts index 58697cbf..14feb1b1 100644 --- a/src/api/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts @@ -34,18 +34,41 @@ import { Request, Response, Router } from "express"; const router: Router = Router(); -router.get("/", route({}), async (req: Request, res: Response) => { - res.json( - await User.findOne({ - select: PrivateUserProjection, - where: { id: req.user_id }, - }), - ); -}); +router.get( + "/", + route({ + responses: { + 200: { + body: "PrivateUserResponse", + }, + }, + }), + async (req: Request, res: Response) => { + res.json( + await User.findOne({ + select: PrivateUserProjection, + where: { id: req.user_id }, + }), + ); + }, +); router.patch( "/", - route({ requestBody: "UserModifySchema" }), + route({ + requestBody: "UserModifySchema", + responses: { + 200: { + body: "UserUpdateResponse", + }, + 400: { + body: "APIErrorResponse", + }, + 404: { + body: "APIErrorResponse", + }, + }, + }), async (req: Request, res: Response) => { const body = req.body as UserModifySchema; -- cgit 1.5.1