summary refs log tree commit diff
path: root/src/api/routes/applications/index.ts
diff options
context:
space:
mode:
authorPuyodead1 <puyodead@proton.me>2023-03-23 11:01:38 -0400
committerPuyodead1 <puyodead@proton.me>2023-04-13 15:00:32 -0400
commit3335f16ad1a6ec114058a8b7e6e71c2cae33c33d (patch)
treeb42f864824fde1b4698687b069c9c5caafae8b0c /src/api/routes/applications/index.ts
parentauth routes (diff)
downloadserver-3335f16ad1a6ec114058a8b7e6e71c2cae33c33d.tar.xz
applications
Diffstat (limited to 'src/api/routes/applications/index.ts')
-rw-r--r--src/api/routes/applications/index.ts37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/api/routes/applications/index.ts b/src/api/routes/applications/index.ts

index 80a19aa8..2290414c 100644 --- a/src/api/routes/applications/index.ts +++ b/src/api/routes/applications/index.ts
@@ -16,28 +16,45 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { Request, Response, Router } from "express"; import { route } from "@spacebar/api"; import { Application, ApplicationCreateSchema, - trimSpecial, User, + trimSpecial, } from "@spacebar/util"; +import { Request, Response, Router } from "express"; const router: Router = Router(); -router.get("/", route({}), async (req: Request, res: Response) => { - const results = await Application.find({ - where: { owner: { id: req.user_id } }, - relations: ["owner", "bot"], - }); - res.json(results).status(200); -}); +router.get( + "/", + route({ + responses: { + 200: { + body: "ApplicationsResponse", + }, + }, + }), + async (req: Request, res: Response) => { + const results = await Application.find({ + where: { owner: { id: req.user_id } }, + relations: ["owner", "bot"], + }); + res.json(results).status(200); + }, +); router.post( "/", - route({ body: "ApplicationCreateSchema" }), + route({ + body: "ApplicationCreateSchema", + responses: { + 200: { + body: "Application", + }, + }, + }), async (req: Request, res: Response) => { const body = req.body as ApplicationCreateSchema; const user = await User.findOneOrFail({ where: { id: req.user_id } });