From 0d0dd4f6b8433a3a90b5b0eebab7e3991bda2302 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Tue, 30 Mar 2021 15:37:43 +0200 Subject: [PATCH] move routes to top level no more /api/v8 -> use reverse proxy instead --- src/routes/assets/index.ts | 34 ------------------- src/routes/{api/v8 => }/auth/login.ts | 0 src/routes/{api/v8 => }/auth/register.ts | 0 .../v8 => }/channels/#channel_id/followers.ts | 0 .../v8 => }/channels/#channel_id/index.ts | 0 .../v8 => }/channels/#channel_id/invites.ts | 0 .../#channel_id/messages/bulk-delete.ts | 0 .../channels/#channel_id/messages/index.ts | 0 .../channels/#channel_id/permissions.ts | 0 .../{api/v8 => }/channels/#channel_id/pins.ts | 0 .../channels/#channel_id/recipients.ts | 0 .../v8 => }/channels/#channel_id/typing.ts | 0 .../v8 => }/channels/#channel_id/webhooks.ts | 0 src/routes/{api/v8 => }/guilds/#id/bans.ts | 0 .../{api/v8 => }/guilds/#id/channels.ts | 0 src/routes/{api/v8 => }/guilds/#id/index.ts | 0 src/routes/{api/v8 => }/guilds/#id/members.ts | 0 src/routes/{api/v8 => }/guilds/index.ts | 0 .../{api/v8 => }/guilds/templates/index.ts | 0 src/routes/{api/v8 => }/invites/index.ts | 0 src/routes/test.ts | 14 -------- src/routes/{api/v8 => }/users/@me/guilds.ts | 0 src/routes/{api/v8 => }/users/@me/index.ts | 0 23 files changed, 48 deletions(-) delete mode 100644 src/routes/assets/index.ts rename src/routes/{api/v8 => }/auth/login.ts (100%) rename src/routes/{api/v8 => }/auth/register.ts (100%) rename src/routes/{api/v8 => }/channels/#channel_id/followers.ts (100%) rename src/routes/{api/v8 => }/channels/#channel_id/index.ts (100%) rename src/routes/{api/v8 => }/channels/#channel_id/invites.ts (100%) rename src/routes/{api/v8 => }/channels/#channel_id/messages/bulk-delete.ts (100%) rename src/routes/{api/v8 => }/channels/#channel_id/messages/index.ts (100%) rename src/routes/{api/v8 => }/channels/#channel_id/permissions.ts (100%) rename src/routes/{api/v8 => }/channels/#channel_id/pins.ts (100%) rename src/routes/{api/v8 => }/channels/#channel_id/recipients.ts (100%) rename src/routes/{api/v8 => }/channels/#channel_id/typing.ts (100%) rename src/routes/{api/v8 => }/channels/#channel_id/webhooks.ts (100%) rename src/routes/{api/v8 => }/guilds/#id/bans.ts (100%) rename src/routes/{api/v8 => }/guilds/#id/channels.ts (100%) rename src/routes/{api/v8 => }/guilds/#id/index.ts (100%) rename src/routes/{api/v8 => }/guilds/#id/members.ts (100%) rename src/routes/{api/v8 => }/guilds/index.ts (100%) rename src/routes/{api/v8 => }/guilds/templates/index.ts (100%) rename src/routes/{api/v8 => }/invites/index.ts (100%) delete mode 100644 src/routes/test.ts rename src/routes/{api/v8 => }/users/@me/guilds.ts (100%) rename src/routes/{api/v8 => }/users/@me/index.ts (100%) diff --git a/src/routes/assets/index.ts b/src/routes/assets/index.ts deleted file mode 100644 index df30d13e..00000000 --- a/src/routes/assets/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * * patch to redirect requests from cloned client - * (../../client/index.html) - */ -import { Router } from "express"; -import fetch, { Response } from "node-fetch"; - -const router: Router = Router(); -const cache = new Map(); -const assetEndpoint = "https://discord.com/assets/"; - -export async function getCache(key: string): Promise { - let cachedRessource = cache.get(key); - - if (!cachedRessource) { - const res = await fetch(assetEndpoint + key); - // @ts-ignore - res.bufferResponse = await res.buffer(); - cache.set(key, res); - cachedRessource = res; - } - - return cachedRessource; -} - -router.get("/:hash", async (req, res) => { - res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24); - const cache = await getCache(req.params.hash); - res.set("content-type", cache.headers.get("content-type")); - // @ts-ignore - res.send(cache.bufferResponse); -}); - -export default router; diff --git a/src/routes/api/v8/auth/login.ts b/src/routes/auth/login.ts similarity index 100% rename from src/routes/api/v8/auth/login.ts rename to src/routes/auth/login.ts diff --git a/src/routes/api/v8/auth/register.ts b/src/routes/auth/register.ts similarity index 100% rename from src/routes/api/v8/auth/register.ts rename to src/routes/auth/register.ts diff --git a/src/routes/api/v8/channels/#channel_id/followers.ts b/src/routes/channels/#channel_id/followers.ts similarity index 100% rename from src/routes/api/v8/channels/#channel_id/followers.ts rename to src/routes/channels/#channel_id/followers.ts diff --git a/src/routes/api/v8/channels/#channel_id/index.ts b/src/routes/channels/#channel_id/index.ts similarity index 100% rename from src/routes/api/v8/channels/#channel_id/index.ts rename to src/routes/channels/#channel_id/index.ts diff --git a/src/routes/api/v8/channels/#channel_id/invites.ts b/src/routes/channels/#channel_id/invites.ts similarity index 100% rename from src/routes/api/v8/channels/#channel_id/invites.ts rename to src/routes/channels/#channel_id/invites.ts diff --git a/src/routes/api/v8/channels/#channel_id/messages/bulk-delete.ts b/src/routes/channels/#channel_id/messages/bulk-delete.ts similarity index 100% rename from src/routes/api/v8/channels/#channel_id/messages/bulk-delete.ts rename to src/routes/channels/#channel_id/messages/bulk-delete.ts diff --git a/src/routes/api/v8/channels/#channel_id/messages/index.ts b/src/routes/channels/#channel_id/messages/index.ts similarity index 100% rename from src/routes/api/v8/channels/#channel_id/messages/index.ts rename to src/routes/channels/#channel_id/messages/index.ts diff --git a/src/routes/api/v8/channels/#channel_id/permissions.ts b/src/routes/channels/#channel_id/permissions.ts similarity index 100% rename from src/routes/api/v8/channels/#channel_id/permissions.ts rename to src/routes/channels/#channel_id/permissions.ts diff --git a/src/routes/api/v8/channels/#channel_id/pins.ts b/src/routes/channels/#channel_id/pins.ts similarity index 100% rename from src/routes/api/v8/channels/#channel_id/pins.ts rename to src/routes/channels/#channel_id/pins.ts diff --git a/src/routes/api/v8/channels/#channel_id/recipients.ts b/src/routes/channels/#channel_id/recipients.ts similarity index 100% rename from src/routes/api/v8/channels/#channel_id/recipients.ts rename to src/routes/channels/#channel_id/recipients.ts diff --git a/src/routes/api/v8/channels/#channel_id/typing.ts b/src/routes/channels/#channel_id/typing.ts similarity index 100% rename from src/routes/api/v8/channels/#channel_id/typing.ts rename to src/routes/channels/#channel_id/typing.ts diff --git a/src/routes/api/v8/channels/#channel_id/webhooks.ts b/src/routes/channels/#channel_id/webhooks.ts similarity index 100% rename from src/routes/api/v8/channels/#channel_id/webhooks.ts rename to src/routes/channels/#channel_id/webhooks.ts diff --git a/src/routes/api/v8/guilds/#id/bans.ts b/src/routes/guilds/#id/bans.ts similarity index 100% rename from src/routes/api/v8/guilds/#id/bans.ts rename to src/routes/guilds/#id/bans.ts diff --git a/src/routes/api/v8/guilds/#id/channels.ts b/src/routes/guilds/#id/channels.ts similarity index 100% rename from src/routes/api/v8/guilds/#id/channels.ts rename to src/routes/guilds/#id/channels.ts diff --git a/src/routes/api/v8/guilds/#id/index.ts b/src/routes/guilds/#id/index.ts similarity index 100% rename from src/routes/api/v8/guilds/#id/index.ts rename to src/routes/guilds/#id/index.ts diff --git a/src/routes/api/v8/guilds/#id/members.ts b/src/routes/guilds/#id/members.ts similarity index 100% rename from src/routes/api/v8/guilds/#id/members.ts rename to src/routes/guilds/#id/members.ts diff --git a/src/routes/api/v8/guilds/index.ts b/src/routes/guilds/index.ts similarity index 100% rename from src/routes/api/v8/guilds/index.ts rename to src/routes/guilds/index.ts diff --git a/src/routes/api/v8/guilds/templates/index.ts b/src/routes/guilds/templates/index.ts similarity index 100% rename from src/routes/api/v8/guilds/templates/index.ts rename to src/routes/guilds/templates/index.ts diff --git a/src/routes/api/v8/invites/index.ts b/src/routes/invites/index.ts similarity index 100% rename from src/routes/api/v8/invites/index.ts rename to src/routes/invites/index.ts diff --git a/src/routes/test.ts b/src/routes/test.ts deleted file mode 100644 index b488d6e4..00000000 --- a/src/routes/test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Router } from "express"; -import { getPermission, MemberModel, db } from "fosscord-server-util"; -import { Types } from "mongoose"; -const router: Router = Router(); - -router.get("/", async (req, res) => { - // @ts-ignore - const perm = await getPermission(813185668657184768n, 813189959920910336n); - console.log(perm); - if (perm.has("ADD_REACTIONS")) console.log("add"); - res.send("OK"); -}); - -export default router; diff --git a/src/routes/api/v8/users/@me/guilds.ts b/src/routes/users/@me/guilds.ts similarity index 100% rename from src/routes/api/v8/users/@me/guilds.ts rename to src/routes/users/@me/guilds.ts diff --git a/src/routes/api/v8/users/@me/index.ts b/src/routes/users/@me/index.ts similarity index 100% rename from src/routes/api/v8/users/@me/index.ts rename to src/routes/users/@me/index.ts