1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-21 18:21:36 +02:00

🐛 fix gateway endpoint

This commit is contained in:
Flam3rboy 2021-08-07 16:46:53 +02:00
parent 6789ef3eea
commit c24e921b28
4 changed files with 449 additions and 341 deletions

799
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@
},
"homepage": "https://github.com/fosscord/fosscord-api#readme",
"dependencies": {
"@fosscord/server-util": "^1.3.37",
"@fosscord/server-util": "^1.3.38",
"@types/jest": "^26.0.22",
"@types/json-schema": "^7.0.7",
"ajv": "^8.4.0",

View File

@ -165,7 +165,10 @@ export class FosscordServer extends Server {
/CDN_HOST: ".+"/,
`CDN_HOST: "${(Config.get().cdn.endpoint || "http://localhost:3003").replace(/https?:/, "")}"`
)
.replace(/GATEWAY_ENDPOINT: ".+"/, `GATEWAY_ENDPOINT: "${Config.get().gateway.endpoint || "ws://localhost:3002"}"`)
.replace(
/GATEWAY_ENDPOINT: ".+"/,
`GATEWAY_ENDPOINT: "${Config.get().gateway.endpoint || process.env.GATEWAY || "ws://localhost:3002"}"`
)
);
});
return super.start();

View File

@ -1,5 +1,5 @@
import { db, MongooseCache, Bucket } from "@fosscord/server-util";
import { NextFunction, Request, Response } from "express";
import { IRouterHandler, NextFunction, Request, Response } from "express";
import { getIpAdress } from "../util/ipAddress";
import { API_PREFIX_TRAILING_SLASH } from "./Authentication";
@ -43,10 +43,10 @@ export default function RateLimit(opts: {
error?: boolean;
success?: boolean;
onylIp?: boolean;
}) {
}): any {
Cache.init(); // will only initalize it once
return async (req: Request, res: Response, next: NextFunction) => {
return async (req: Request, res: Response, next: NextFunction): Promise<any> => {
const bucket_id = opts.bucket || req.originalUrl.replace(API_PREFIX_TRAILING_SLASH, "");
var user_id = getIpAdress(req);
if (!opts.onylIp && req.user_id) user_id = req.user_id;