Testing error handling and rate limiting - it seems broken
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
|
import {Logger} from '../../../models/logger';
|
||||||
|
|
||||||
export class ErrorHandler {
|
export class ErrorHandler {
|
||||||
static async newError(err, req, res, next) {
|
static async newError(err, req, res, next) {
|
||||||
|
Logger.error(err);
|
||||||
|
res.end('an error has occured');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ export class RateLimits extends MiddleWare {
|
|||||||
MiddleWare.analytics(req, res, next);
|
MiddleWare.analytics(req, res, next);
|
||||||
|
|
||||||
if (!buckets[ip]) {
|
if (!buckets[ip]) {
|
||||||
Logger.debug(`New rate limiting bucket`);
|
Logger.debug(`New rate limiting bucket for ${ip}`);
|
||||||
RateLimits.newBucket(ip);
|
RateLimits.newBucket(ip);
|
||||||
|
next();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ export class RateLimits extends MiddleWare {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buckets[ip].tokens.pop();
|
buckets[ip].tokens.pop();
|
||||||
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
static newBucket(ip) {
|
static newBucket(ip) {
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ export class Router {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static frontPage(req, res, next) {
|
static frontPage(req, res, next) {
|
||||||
|
// const err = "lol";
|
||||||
|
// next(err);
|
||||||
res.end('DEVELOPMENT SERVER');
|
res.end('DEVELOPMENT SERVER');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user