added rate limiting

This commit is contained in:
Ben
2018-09-01 19:57:51 +01:00
parent c33f7bdd7b
commit 8ef777ae44
8 changed files with 82 additions and 17 deletions

View File

@@ -21,19 +21,18 @@ export class APIErrors extends API {
}
addError(statusCode, message, verbose) {
verbose = verbose || message;
this.errors.error.errors.push({status: statusCode, title: message, detail: verbose});
this.errors.status.code = statusCode;
this.errors.status.type = message;
this.errors.status.message = verbose;
}
count() {
return this.errors.error.errors.length;
}
count() { return this.errors.error.errors.length }
endpoint() {
this.res.setHeader('Content-type', 'application/json');
this.res.status(this.errors.status.code);
this.res.end(JSON.stringify(this.errors, false, 4));
this.res
.status(this.errors.status.code)
.end(JSON.stringify(this.errors, false, 4));
}
}

View File

@@ -27,8 +27,9 @@ export class User extends API {
}
endpoint() {
this.res.setHeader('Content-type', 'application/json');
this.res.status(200);
this.res.end(JSON.stringify(this.response, false, 4));
this.res
.setHeader('Content-type', 'application/json')
.status(200)
.end(JSON.stringify(this.response, false, 4));
}
}