From 4f6e59e936dd9dfc10bebe7ac10dea8c0d96e6ec Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Wed, 10 Aug 2022 02:53:29 -0600 Subject: Add basic developer panel functionality - doesn't work yet > > > Co-authored-by: TheArcaneBrony --- api/src/routes/applications/#id/index.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 api/src/routes/applications/#id/index.ts (limited to 'api/src/routes/applications/#id/index.ts') diff --git a/api/src/routes/applications/#id/index.ts b/api/src/routes/applications/#id/index.ts new file mode 100644 index 00000000..be8c3ba4 --- /dev/null +++ b/api/src/routes/applications/#id/index.ts @@ -0,0 +1,27 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; +import { Application, OrmUtils, Team, trimSpecial, User } from "@fosscord/util"; + +const router: Router = Router(); + +router.get("/", route({}), async (req: Request, res: Response) => { + //TODO + let results = await Application.findOne({where: {id: req.params.id}, relations: ["owner", "bot"] }); + //debugger; + res.json(results).status(200); +}); + +router.patch("/", route({}), async (req: Request, res: Response) => { + delete req.body.icon; + let app = OrmUtils.mergeDeep(await Application.findOne({where: {id: req.params.id}, relations: ["owner", "bot"]}), req.body); + if(app.bot) { + app.bot.bio = req.body.description + app.bot?.save(); + } + if(req.body.tags) app.tags = req.body.tags; + await app.save(); + debugger; + res.json(app).status(200); +}); + +export default router; \ No newline at end of file -- cgit 1.5.1 From 4fe40c2a2016cce4278fbb40093c38145b36e0ea Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Wed, 10 Aug 2022 03:52:03 -0600 Subject: It works now... I guess Co-authored-by: TheArcaneBrony --- api/src/routes/applications/#id/index.ts | 1 - api/src/routes/applications/index.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'api/src/routes/applications/#id/index.ts') diff --git a/api/src/routes/applications/#id/index.ts b/api/src/routes/applications/#id/index.ts index be8c3ba4..a16b18a9 100644 --- a/api/src/routes/applications/#id/index.ts +++ b/api/src/routes/applications/#id/index.ts @@ -7,7 +7,6 @@ const router: Router = Router(); router.get("/", route({}), async (req: Request, res: Response) => { //TODO let results = await Application.findOne({where: {id: req.params.id}, relations: ["owner", "bot"] }); - //debugger; res.json(results).status(200); }); diff --git a/api/src/routes/applications/index.ts b/api/src/routes/applications/index.ts index c9be1131..41ce35b5 100644 --- a/api/src/routes/applications/index.ts +++ b/api/src/routes/applications/index.ts @@ -11,7 +11,7 @@ export interface ApplicationCreateSchema { router.get("/", route({}), async (req: Request, res: Response) => { //TODO - let results = await Application.find({where: {owner: {id: req.user_id}}, relations: ["owner"] }); + let results = await Application.find({where: {owner: {id: req.user_id}}, relations: ["owner", "bot"] }); res.json(results).status(200); }); -- cgit 1.5.1 From e041945eccbd3f5241e4ef62239d207c180bd466 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Wed, 10 Aug 2022 04:29:14 -0600 Subject: I'm probably forgetting a lot of things, but hey, it works --- api/src/routes/applications/#id/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'api/src/routes/applications/#id/index.ts') diff --git a/api/src/routes/applications/#id/index.ts b/api/src/routes/applications/#id/index.ts index a16b18a9..24df2d88 100644 --- a/api/src/routes/applications/#id/index.ts +++ b/api/src/routes/applications/#id/index.ts @@ -5,7 +5,6 @@ import { Application, OrmUtils, Team, trimSpecial, User } from "@fosscord/util"; const router: Router = Router(); router.get("/", route({}), async (req: Request, res: Response) => { - //TODO let results = await Application.findOne({where: {id: req.params.id}, relations: ["owner", "bot"] }); res.json(results).status(200); }); @@ -23,4 +22,10 @@ router.patch("/", route({}), async (req: Request, res: Response) => { res.json(app).status(200); }); +router.post("/delete", route({}), async (req: Request, res: Response) => { + await Application.delete(req.params.id); + res.send().status(200); +}); + + export default router; \ No newline at end of file -- cgit 1.5.1 From f79baa7b2cb58106ad2ffb69ce6166ce821c5d29 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Wed, 10 Aug 2022 04:35:10 -0600 Subject: Whoops, missed one --- api/src/routes/applications/#id/index.ts | 1 - 1 file changed, 1 deletion(-) (limited to 'api/src/routes/applications/#id/index.ts') diff --git a/api/src/routes/applications/#id/index.ts b/api/src/routes/applications/#id/index.ts index 24df2d88..0aced582 100644 --- a/api/src/routes/applications/#id/index.ts +++ b/api/src/routes/applications/#id/index.ts @@ -18,7 +18,6 @@ router.patch("/", route({}), async (req: Request, res: Response) => { } if(req.body.tags) app.tags = req.body.tags; await app.save(); - debugger; res.json(app).status(200); }); -- cgit 1.5.1