aboutsummaryrefslogtreecommitdiff
path: root/build/index.js
diff options
context:
space:
mode:
authormat-1 <github@matdoes.dev>2021-03-25 03:30:19 +0000
committermat-1 <github@matdoes.dev>2021-03-25 03:30:19 +0000
commit39ee05a817807dc053393db8757072e7c9a98b76 (patch)
tree865fed1f5992f5a7e1a9bc37cd6e446edf8624f4 /build/index.js
parent859e14a96e1885b814eb99f1c5a9beb8adfdb591 (diff)
downloadskyblock-api-39ee05a817807dc053393db8757072e7c9a98b76.tar.gz
skyblock-api-39ee05a817807dc053393db8757072e7c9a98b76.tar.bz2
skyblock-api-39ee05a817807dc053393db8757072e7c9a98b76.zip
Compiled TS into JS
Diffstat (limited to 'build/index.js')
-rw-r--r--build/index.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/build/index.js b/build/index.js
index 11b2fc6..ff59b7c 100644
--- a/build/index.js
+++ b/build/index.js
@@ -7,14 +7,18 @@ exports.debug = void 0;
const hypixel_1 = require("./hypixel");
const express_1 = __importDefault(require("express"));
const database_1 = require("./database");
+const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
const app = express_1.default();
exports.debug = false;
-app.use((req, res, next) => {
- if (process.env.key && req.headers.key !== process.env.key)
- // if a key is set in process.env and the header doesn't match return an error
- return res.status(401).json({ error: 'Key in header must match key in env' });
- next();
+// 250 requests over 5 minutes
+const limiter = express_rate_limit_1.default({
+ windowMs: 60 * 1000 * 5,
+ max: 250,
+ skip: (req, res) => {
+ return req.headers.key === process.env.key;
+ }
});
+app.use(limiter);
app.get('/', async (req, res) => {
res.json({ ok: true });
});