Add gateway pings #20

Merged
hippoz merged 4 commits from gateway-pings into master 2021-09-08 00:28:28 +03:00
3 changed files with 3 additions and 4 deletions
Showing only changes of commit 680aab399b - Show all commits

View file

@ -1,6 +1,5 @@
module.exports = { module.exports = {
"env": { "env": {
"browser": true,
"commonjs": true, "commonjs": true,
"es2021": true, "es2021": true,
"node": true "node": true

View file

@ -10,7 +10,7 @@ class RateLimiter {
} }
} }
RateLimiter.prototype.consoom = function(discriminator) { RateLimiter.prototype.consume = function(discriminator) {
if (!this._flooding[discriminator]) this._flooding[discriminator] = { points: this.points, lastReset: Date.now() }; if (!this._flooding[discriminator]) this._flooding[discriminator] = { points: this.points, lastReset: Date.now() };
if (Math.abs(new Date() - this._flooding[discriminator].lastReset) >= this.time) { if (Math.abs(new Date() - this._flooding[discriminator].lastReset) >= this.time) {

View file

@ -30,10 +30,10 @@ app.use("/api/v1", apiRoute);
app.use(express.static("app")); app.use(express.static("app"));
app.use((err, req, res, next) => { app.use((err, req, res, next) => {
console.error("error: Internal server error", err); console.error("error: server: internal server error", err);
res.status(500).json({ error: true, status: 500, message: "ERR_INTERNAL_SERVER_ERROR" }); res.status(500).json({ error: true, status: 500, message: "ERR_INTERNAL_SERVER_ERROR" });
}); });
httpServer.listen(config.ports.mainServerPort, () => { httpServer.listen(config.ports.mainServerPort, () => {
console.log(`[*] [server] Main server is listening on port ${config.ports.mainServerPort}`); console.log(`server: listening on port ${config.ports.mainServerPort}`);
}); });