fixed bug where res would time out

This commit is contained in:
plane000
2018-09-01 21:30:46 +01:00
parent 5f7313cd0d
commit 47a76e2f5b
7 changed files with 14 additions and 17 deletions

View File

@@ -10,7 +10,7 @@ export class RateLimits extends MiddleWare{
let ip = req.connection.remoteAddress;
if (!buckets[ip]) {
console.log(`New bucket`)
Logger.debug(`New rate limiting bucket`);
RateLimits.newBucket(ip);
next();
return;

View File

@@ -12,13 +12,13 @@ export class Router {
app = Server.App;
app.get('/', [MiddleWare.end, Router.frontPage]);
app.get('/', [MiddleWare.RateLimits.request, MiddleWare.analytics, Router.frontPage]);
app.get('/user/:id', [MiddleWare.end]);
app.delete('/user/:id', [MiddleWare.end]);
app.post('/user', [MiddleWare.end, Controllers.UserController.newUser]);
app.get('/user/:id', [MiddleWare.RateLimits.request, MiddleWare.analytics,]);
app.delete('/user/:id', [MiddleWare.RateLimits.request, MiddleWare.analytics,]);
app.post('/user', [MiddleWare.RateLimits.request, MiddleWare.analytics, Controllers.UserController.newUser]);
app.use([StatusCodes.pageNotFound]);
app.get('*', [MiddleWare.RateLimits.request, StatusCodes.pageNotFound]);
Logger.info('HTTP endpoints settup');
}

View File

@@ -24,8 +24,8 @@ export class UserController extends ControllerHandler {
if (!UserController.isPasswordValid(password)) errors.addError(422, 'Unprocessaable entity', 'Invalid password has spaces');
if (password.length < 7) errors.addError(422, 'Unprocessaable entity', 'Invalid password less than 7 charicters');
if (await Database.users.getID('username', username) == -1) errors.addError(422, 'Unprocessable entity', 'A user with that username allready exists');
if (await Database.users.getID('email', email) == -1) errors.addError(422, 'Unprocessable entity', 'A user with that email allready exists');
if (await Database.users.getID('username', username) != -1) errors.addError(422, 'Unprocessable entity', 'A user with that username allready exists');
if (await Database.users.getID('email', email) != -1) errors.addError(422, 'Unprocessable entity', 'A user with that email allready exists');
let id = new Date().getTime();
let token = "1234";