summary refs log tree commit diff
path: root/src/api/routes/applications
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/routes/applications')
-rw-r--r--src/api/routes/applications/#id/bot/index.ts26
-rw-r--r--src/api/routes/applications/#id/entitlements.ts2
-rw-r--r--src/api/routes/applications/#id/index.ts35
-rw-r--r--src/api/routes/applications/#id/skus.ts2
-rw-r--r--src/api/routes/applications/detectable.ts2
-rw-r--r--src/api/routes/applications/index.ts13
6 files changed, 24 insertions, 56 deletions
diff --git a/src/api/routes/applications/#id/bot/index.ts b/src/api/routes/applications/#id/bot/index.ts
index 3c431e3d..5d58e6ed 100644
--- a/src/api/routes/applications/#id/bot/index.ts
+++ b/src/api/routes/applications/#id/bot/index.ts
@@ -50,15 +50,14 @@ router.post(
 			relations: ["owner"],
 		});
 
-		if (app.owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+		if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
 
 		const user = await createAppBotUser(app, req);
 
 		res.send({
 			token: await generateToken(user.id),
 		}).status(204);
-	},
+	}
 );
 
 router.post(
@@ -77,13 +76,9 @@ router.post(
 		const bot = await User.findOneOrFail({ where: { id: req.params.id } });
 		const owner = await User.findOneOrFail({ where: { id: req.user_id } });
 
-		if (owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+		if (owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
 
-		if (
-			owner.totp_secret &&
-			(!req.body.code || verifyToken(owner.totp_secret, req.body.code))
-		)
+		if (owner.totp_secret && (!req.body.code || verifyToken(owner.totp_secret, req.body.code)))
 			throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008);
 
 		bot.data = { hash: undefined, valid_tokens_since: new Date() };
@@ -93,7 +88,7 @@ router.post(
 		const token = await generateToken(bot.id);
 
 		res.json({ token }).status(200);
-	},
+	}
 );
 
 router.patch(
@@ -120,14 +115,9 @@ router.patch(
 
 		if (!app.bot) throw DiscordApiErrors.BOT_ONLY_ENDPOINT;
 
-		if (app.owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+		if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
 
-		if (body.avatar)
-			body.avatar = await handleFile(
-				`/avatars/${app.id}`,
-				body.avatar as string,
-			);
+		if (body.avatar) body.avatar = await handleFile(`/avatars/${app.id}`, body.avatar as string);
 
 		app.bot.assign(body);
 
@@ -135,7 +125,7 @@ router.patch(
 
 		await app.save();
 		res.json(app).status(200);
-	},
+	}
 );
 
 export default router;
diff --git a/src/api/routes/applications/#id/entitlements.ts b/src/api/routes/applications/#id/entitlements.ts
index 6388e6b3..4ad0b60f 100644
--- a/src/api/routes/applications/#id/entitlements.ts
+++ b/src/api/routes/applications/#id/entitlements.ts
@@ -34,7 +34,7 @@ router.get(
 		// TODO:
 		//const { exclude_consumed } = req.query;
 		res.status(200).send([]);
-	},
+	}
 );
 
 export default router;
diff --git a/src/api/routes/applications/#id/index.ts b/src/api/routes/applications/#id/index.ts
index c372869a..9b8c2d46 100644
--- a/src/api/routes/applications/#id/index.ts
+++ b/src/api/routes/applications/#id/index.ts
@@ -17,11 +17,7 @@
 */
 
 import { route } from "@spacebar/api";
-import {
-	Application,
-	ApplicationModifySchema,
-	DiscordApiErrors,
-} from "@spacebar/util";
+import { Application, ApplicationModifySchema, DiscordApiErrors } from "@spacebar/util";
 import { Request, Response, Router } from "express";
 import { HTTPError } from "lambert-server";
 import { verifyToken } from "node-2fa";
@@ -45,11 +41,10 @@ router.get(
 			where: { id: req.params.id },
 			relations: ["owner", "bot"],
 		});
-		if (app.owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+		if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
 
 		return res.json(app);
-	},
+	}
 );
 
 router.patch(
@@ -73,14 +68,9 @@ router.patch(
 			relations: ["owner", "bot"],
 		});
 
-		if (app.owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+		if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
 
-		if (
-			app.owner.totp_secret &&
-			(!req.body.code ||
-				verifyToken(app.owner.totp_secret, req.body.code))
-		)
+		if (app.owner.totp_secret && (!req.body.code || verifyToken(app.owner.totp_secret, req.body.code)))
 			throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008);
 
 		if (app.bot) {
@@ -93,7 +83,7 @@ router.patch(
 		await app.save();
 
 		return res.json(app);
-	},
+	}
 );
 
 router.post(
@@ -111,20 +101,15 @@ router.post(
 			where: { id: req.params.id },
 			relations: ["bot", "owner"],
 		});
-		if (app.owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
-
-		if (
-			app.owner.totp_secret &&
-			(!req.body.code ||
-				verifyToken(app.owner.totp_secret, req.body.code))
-		)
+		if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+
+		if (app.owner.totp_secret && (!req.body.code || verifyToken(app.owner.totp_secret, req.body.code)))
 			throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008);
 
 		await Application.delete({ id: app.id });
 
 		res.send().status(200);
-	},
+	}
 );
 
 export default router;
diff --git a/src/api/routes/applications/#id/skus.ts b/src/api/routes/applications/#id/skus.ts
index dc4fad23..b98bb6c4 100644
--- a/src/api/routes/applications/#id/skus.ts
+++ b/src/api/routes/applications/#id/skus.ts
@@ -32,7 +32,7 @@ router.get(
 	}),
 	async (req: Request, res: Response) => {
 		res.json([]).status(200);
-	},
+	}
 );
 
 export default router;
diff --git a/src/api/routes/applications/detectable.ts b/src/api/routes/applications/detectable.ts
index 5cf9d171..e80d0313 100644
--- a/src/api/routes/applications/detectable.ts
+++ b/src/api/routes/applications/detectable.ts
@@ -33,7 +33,7 @@ router.get(
 	async (req: Request, res: Response) => {
 		//TODO
 		res.send([]).status(200);
-	},
+	}
 );
 
 export default router;
diff --git a/src/api/routes/applications/index.ts b/src/api/routes/applications/index.ts
index 5bba3338..6eeadbc3 100644
--- a/src/api/routes/applications/index.ts
+++ b/src/api/routes/applications/index.ts
@@ -17,14 +17,7 @@
 */
 
 import { route } from "@spacebar/api";
-import {
-	Application,
-	ApplicationCreateSchema,
-	Config,
-	User,
-	createAppBotUser,
-	trimSpecial,
-} from "@spacebar/util";
+import { Application, ApplicationCreateSchema, Config, User, createAppBotUser, trimSpecial } from "@spacebar/util";
 import { Request, Response, Router } from "express";
 
 const router: Router = Router();
@@ -44,7 +37,7 @@ router.get(
 			relations: ["owner", "bot"],
 		});
 		res.json(results).status(200);
-	},
+	}
 );
 
 router.post(
@@ -77,7 +70,7 @@ router.post(
 		} else await app.save();
 
 		res.json(app);
-	},
+	}
 );
 
 export default router;