summary refs log tree commit diff
path: root/src/routes
diff options
context:
space:
mode:
authorDiego Magdaleno <diegomagdaleno@protonmail.com>2021-05-22 18:51:46 -0500
committerDiego Magdaleno <diegomagdaleno@protonmail.com>2021-05-22 18:51:46 -0500
commitff7985ad7d214cd2c7b5c2341aaa878edc826d20 (patch)
tree6dde0f5357c25ea5c4f279f81b903d3b2386f6c3 /src/routes
parentFix merge issues, update to reflect config changes and package.json (diff)
downloadserver-ff7985ad7d214cd2c7b5c2341aaa878edc826d20.tar.xz
Config: Final config additons, now everything should work as desired
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/auth/login.ts4
-rw-r--r--src/routes/auth/register.ts2
-rw-r--r--src/routes/channels/#channel_id/messages/bulk-delete.ts2
-rw-r--r--src/routes/channels/#channel_id/pins.ts2
-rw-r--r--src/routes/gateway.ts2
-rw-r--r--src/routes/guilds/index.ts2
-rw-r--r--src/routes/guilds/templates/index.ts2
7 files changed, 8 insertions, 8 deletions
diff --git a/src/routes/auth/login.ts b/src/routes/auth/login.ts

index 1938b794..275f78c6 100644 --- a/src/routes/auth/login.ts +++ b/src/routes/auth/login.ts
@@ -27,7 +27,7 @@ router.post( // TODO: Rewrite this to have the proper config syntax on the new method - const config = Config.apiConfig.getAll(); + const config = Config.apiConfig.getAll() as Config.DefaultOptions; if (config.login.requireCaptcha && config.security.captcha.enabled) { if (!captcha_key) { @@ -71,7 +71,7 @@ export async function generateToken(id: string) { return new Promise((res, rej) => { jwt.sign( { id: id, iat }, - Config.apiConfig.getAll().security.jwtSecret, + (Config.apiConfig.getAll() as Config.DefaultOptions).security.jwtSecret, { algorithm, }, diff --git a/src/routes/auth/register.ts b/src/routes/auth/register.ts
index ca6351fa..b52b5cf3 100644 --- a/src/routes/auth/register.ts +++ b/src/routes/auth/register.ts
@@ -52,7 +52,7 @@ router.post( let discriminator = ""; // get register Config - const { register, security } = Config.apiConfig.getAll(); + const { register, security } = Config.apiConfig.getAll() as Config.DefaultOptions; // check if registration is allowed if (!register.allowNewRegistration) { diff --git a/src/routes/channels/#channel_id/messages/bulk-delete.ts b/src/routes/channels/#channel_id/messages/bulk-delete.ts
index 8a11475e..615a0d7d 100644 --- a/src/routes/channels/#channel_id/messages/bulk-delete.ts +++ b/src/routes/channels/#channel_id/messages/bulk-delete.ts
@@ -20,7 +20,7 @@ router.post("/", check({ messages: [String] }), async (req, res) => { const permission = await getPermission(req.user_id, channel?.guild_id, channel_id, { channel }); permission.hasThrow("MANAGE_MESSAGES"); - const { maxBulkDelete } = Config.apiConfig.getAll().limits.message; + const { maxBulkDelete } = (Config.apiConfig.getAll() as Config.DefaultOptions).limits.message; const { messages } = req.body as { messages: string[] }; if (messages.length < 2) throw new HTTPError("You must at least specify 2 messages to bulk delete"); diff --git a/src/routes/channels/#channel_id/pins.ts b/src/routes/channels/#channel_id/pins.ts
index ccb909b8..6d938b79 100644 --- a/src/routes/channels/#channel_id/pins.ts +++ b/src/routes/channels/#channel_id/pins.ts
@@ -18,7 +18,7 @@ router.put("/:message_id", async (req: Request, res: Response) => { if (channel.guild_id) permission.hasThrow("MANAGE_MESSAGES"); const pinned_count = await MessageModel.count({ channel_id, pinned: true }).exec(); - const { maxPins } = Config.apiConfig.getAll().limits.channel; + const { maxPins } = (Config.apiConfig.getAll() as Config.DefaultOptions).limits.channel; if (pinned_count >= maxPins) throw new HTTPError("Max pin count reached: " + maxPins); await MessageModel.updateOne({ id: message_id }, { pinned: true }).exec(); diff --git a/src/routes/gateway.ts b/src/routes/gateway.ts
index 04ab1248..8d0eb06f 100644 --- a/src/routes/gateway.ts +++ b/src/routes/gateway.ts
@@ -4,7 +4,7 @@ import * as Config from "../util/Config" const router = Router(); router.get("/", (req, res) => { - const { gateway } = Config.apiConfig.getAll(); + const { gateway } = Config.apiConfig.getAll() as Config.DefaultOptions; res.send({ url: gateway || "ws://localhost:3002" }); }); diff --git a/src/routes/guilds/index.ts b/src/routes/guilds/index.ts
index 8860bcdf..9e787e5b 100644 --- a/src/routes/guilds/index.ts +++ b/src/routes/guilds/index.ts
@@ -15,7 +15,7 @@ const router: Router = Router(); router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) => { const body = req.body as GuildCreateSchema; - const { maxGuilds } = Config.apiConfig.getAll().limits.user; + const { maxGuilds } = (Config.apiConfig.getAll() as Config.DefaultOptions).limits.user; const user = await getPublicUser(req.user_id, { guilds: true }); if (user.guilds.length >= maxGuilds) { diff --git a/src/routes/guilds/templates/index.ts b/src/routes/guilds/templates/index.ts
index a7af8295..21a3a6aa 100644 --- a/src/routes/guilds/templates/index.ts +++ b/src/routes/guilds/templates/index.ts
@@ -21,7 +21,7 @@ router.post("/:code", check(GuildTemplateCreateSchema), async (req: Request, res const { code } = req.params; const body = req.body as GuildTemplateCreateSchema; - const { maxGuilds } = Config.apiConfig.getAll().limits.user; + const { maxGuilds } = (Config.apiConfig.getAll() as Config.DefaultOptions).limits.user; const user = await getPublicUser(req.user_id, { guilds: true }); if (user.guilds.length >= maxGuilds) {