exempts 'special' role from rate limiting

This commit is contained in:
nai-degen
2023-10-06 20:29:28 -05:00
parent daf6a123d5
commit 12f78fa1f2
3 changed files with 4 additions and 6 deletions
@@ -7,7 +7,7 @@ export const setApiFormat = (api: {
outApi: APIFormat;
service: LLMService,
}): RequestPreprocessor => {
return (req) => {
return function configureRequestApiFormat (req) {
req.inboundApi = api.inApi;
req.outboundApi = api.outApi;
req.service = api.service;
+2 -4
View File
@@ -63,10 +63,8 @@ export const ipLimiter = async (
res: Response,
next: NextFunction
) => {
if (!RATE_LIMIT_ENABLED) {
next();
return;
}
if (!RATE_LIMIT_ENABLED) return next();
if (req.user?.type === "special") return next();
// Exempt Agnai.chat from rate limiting since it's shared between a lot of
// users. Dunno how to prevent this from being abused without some sort of
+1 -1
View File
@@ -1,7 +1,7 @@
import type { HttpRequest } from "@smithy/types";
import { Express } from "express-serve-static-core";
import { APIFormat, Key, LLMService } from "../shared/key-management";
import { User } from "../shared/users/user-store";
import { User } from "../shared/users/schema";
declare global {
namespace Express {