summary refs log tree commit diff
path: root/src/api/routes/applications/#id/index.ts
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-08-22 22:18:59 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-08-22 22:18:59 +1000
commit0cd9a46eea260c299db2e2983f7214ab8b119d29 (patch)
tree5fbb98e7adcfeab81594732089474afdde5893f9 /src/api/routes/applications/#id/index.ts
parentMerge branch 'master' into feat/captchaVerify (diff)
parentMerge remote-tracking branch 'Puyodead1/patch/prettier-config' into staging (diff)
downloadserver-0cd9a46eea260c299db2e2983f7214ab8b119d29.tar.xz
Merge remote-tracking branch 'upstream/staging' into feat/captchaVerify
Diffstat (limited to 'src/api/routes/applications/#id/index.ts')
-rw-r--r--src/api/routes/applications/#id/index.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/api/routes/applications/#id/index.ts b/src/api/routes/applications/#id/index.ts
new file mode 100644
index 00000000..0aced582
--- /dev/null
+++ b/src/api/routes/applications/#id/index.ts
@@ -0,0 +1,30 @@
+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) => {
+	let results = await Application.findOne({where: {id: req.params.id}, relations: ["owner", "bot"] });
+	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();
+	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