aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-08-25 05:03:20 +0000
committerAdam Soltys <[email protected]>2024-08-25 05:03:23 +0000
commitc5c201b441e0b1ef7d0df19bd936d0ccfa9e601c (patch)
tree4929300229dc38c676f9deb0a44d0974806f3c85
parent2a60293dd7e1c04df37660e5df2604c43bcad000 (diff)
downloadcoinos-server-c5c201b441e0b1ef7d0df19bd936d0ccfa9e601c.tar.gz
coinos-server-c5c201b441e0b1ef7d0df19bd936d0ccfa9e601c.zip
squelch rate errors
-rw-r--r--index.js2
-rw-r--r--lib/app.js9
2 files changed, 9 insertions, 2 deletions
diff --git a/index.js b/index.js
index 376bca71..65fb9368 100644
--- a/index.js
+++ b/index.js
@@ -133,7 +133,7 @@ app.listen({ host, port });
let logerr = (e) =>
e.message.includes("Invalid") ||
e.message.includes("MASK") ||
- e.message.startsWith("Rate") ||
+ e.message.includes("Rate") ||
console.log(e);
process.on("unhandledRejection", logerr);
diff --git a/lib/app.js b/lib/app.js
index fee3b8b6..56584107 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -24,6 +24,13 @@ await app.register(import("@fastify/rate-limit"), {
max: 100,
timeWindow: 2000,
keyGenerator: (req) => req.headers["cf-connecting-ip"],
+ errorResponseBuilder: (req, context) => {
+ return {
+ statusCode: 429,
+ error: "Too Many Requests",
+ message: "Rate limit exceeded, retry in 2 seconds",
+ };
+ },
});
app.register(fastifySecureSession, {
@@ -35,7 +42,7 @@ app.register(fastifyPassport.secureSession());
fastifyPassport.use("jwt", jwtStrategy);
- app.register(fastifyMultipart, { limits: { fileSize: 10 ** 7}});
+app.register(fastifyMultipart, { limits: { fileSize: 10 ** 7 } });
app.register(fastifyStatic, {
root: path.join("/app/data/uploads"),