mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 05:02:37 +01:00
move routes to top level no more /api/v8 -> use reverse proxy instead
This commit is contained in:
parent
9050415611
commit
0d0dd4f6b8
@ -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<string, Response>();
|
||||
const assetEndpoint = "https://discord.com/assets/";
|
||||
|
||||
export async function getCache(key: string): Promise<Response> {
|
||||
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", <string>cache.headers.get("content-type"));
|
||||
// @ts-ignore
|
||||
res.send(cache.bufferResponse);
|
||||
});
|
||||
|
||||
export default router;
|
@ -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;
|
Loading…
Reference in New Issue
Block a user