switch to mongoose

This commit is contained in:
Flam3rboy
2021-02-14 19:01:41 +01:00
parent 52ef9f7a3e
commit a94f7c7617
11 changed files with 121 additions and 99 deletions
+2
View File
@@ -6,6 +6,8 @@ import { db } from "fosscord-server-util";
// TODO: increment count on serverside
export async function GlobalRateLimit(req: Request, res: Response, next: NextFunction) {
return next();
// TODO: use new db mongoose models
if (!Config.get().limits.rate.ip.enabled) return next();
const ip = getIpAdress(req);
+3
View File
@@ -5,6 +5,9 @@ import { getIpAdress } from "./GlobalRateLimit";
export function RateLimit({ count = 10, timespan = 1000 * 5, name = "/" }) {
return async (req: Request, res: Response, next: NextFunction) => {
return next();
// TODO: use new db mongoose models
let id = req.userid || getIpAdress(req);
const limit: { count: number; start: number } = (await db.data.ratelimit.routes[name][id].get()) || {