summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-20 23:35:32 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-20 23:35:32 +0200
commit022e82023d1a5a91e671eacf5ce054e097f379f7 (patch)
tree88bdc12deb06869457ceb9ce910d0d31623d3799 /api
parent:bug: fix errror handler (diff)
downloadserver-022e82023d1a5a91e671eacf5ce054e097f379f7.tar.xz
:sparkles: add option to disable all rate limits
Diffstat (limited to 'api')
-rw-r--r--api/src/middlewares/BodyParser.ts2
-rw-r--r--api/src/middlewares/RateLimit.ts3
2 files changed, 4 insertions, 1 deletions
diff --git a/api/src/middlewares/BodyParser.ts b/api/src/middlewares/BodyParser.ts
index b0ff699d..4cb376bc 100644
--- a/api/src/middlewares/BodyParser.ts
+++ b/api/src/middlewares/BodyParser.ts
@@ -6,6 +6,8 @@ export function BodyParser(opts?: OptionsJson) {
 	const jsonParser = bodyParser.json(opts);
 
 	return (req: Request, res: Response, next: NextFunction) => {
+		if (!req.headers["content-type"]) req.headers["content-type"] = "application/json";
+
 		jsonParser(req, res, (err) => {
 			if (err) {
 				// TODO: different errors for body parser (request size limit, wrong body type, invalid body, ...)
diff --git a/api/src/middlewares/RateLimit.ts b/api/src/middlewares/RateLimit.ts
index d1fd072f..1a38cfcf 100644
--- a/api/src/middlewares/RateLimit.ts
+++ b/api/src/middlewares/RateLimit.ts
@@ -107,7 +107,8 @@ export default function rateLimit(opts: {
 }
 
 export async function initRateLimits(app: Router) {
-	const { routes, global, ip, error } = Config.get().limits.rate;
+	const { routes, global, ip, error, disabled } = Config.get().limits.rate;
+	if (disabled) return;
 	await listenEvent(EventRateLimit, (event) => {
 		Cache.set(event.channel_id as string, event.data);
 		event.acknowledge?.();