diff --git a/apps/client/src/components/game/game-machine.tsx b/apps/client/src/components/game/game-machine.tsx index f925321..0e92a1b 100644 --- a/apps/client/src/components/game/game-machine.tsx +++ b/apps/client/src/components/game/game-machine.tsx @@ -104,7 +104,7 @@ export const gameMachine = createMachine( faceOffResults: { after: { - 20000: [ + 18000: [ { target: "winnerLeadUp", cond: "completedRounds", diff --git a/apps/client/src/components/game/game-machine.typegen.ts b/apps/client/src/components/game/game-machine.typegen.ts index d374581..acb38b6 100644 --- a/apps/client/src/components/game/game-machine.typegen.ts +++ b/apps/client/src/components/game/game-machine.typegen.ts @@ -6,8 +6,8 @@ export interface Typegen0 { "xstate.after(10000)#Machine.winner": { type: "xstate.after(10000)#Machine.winner"; }; - "xstate.after(20000)#Machine.faceOffResults": { - type: "xstate.after(20000)#Machine.faceOffResults"; + "xstate.after(18000)#Machine.faceOffResults": { + type: "xstate.after(18000)#Machine.faceOffResults"; }; "xstate.after(4000)#Machine.nextRound": { type: "xstate.after(4000)#Machine.nextRound"; @@ -34,14 +34,14 @@ export interface Typegen0 { services: never; }; eventsCausingActions: { - incrementQuestionIdx: "xstate.after(20000)#Machine.faceOffResults"; + incrementQuestionIdx: "xstate.after(18000)#Machine.faceOffResults"; resetContext: "NEXT"; - startNewRound: "xstate.after(20000)#Machine.faceOffResults"; + startNewRound: "xstate.after(18000)#Machine.faceOffResults"; }; eventsCausingDelays: {}; eventsCausingGuards: { - completedCurrentRound: "xstate.after(20000)#Machine.faceOffResults"; - completedRounds: "xstate.after(20000)#Machine.faceOffResults"; + completedCurrentRound: "xstate.after(18000)#Machine.faceOffResults"; + completedRounds: "xstate.after(18000)#Machine.faceOffResults"; }; eventsCausingServices: {}; matchesStates: diff --git a/apps/server/src/server.ts b/apps/server/src/server.ts index 537d94e..9671e93 100644 --- a/apps/server/src/server.ts +++ b/apps/server/src/server.ts @@ -67,13 +67,6 @@ export function buildServer() { // Rate limiter // Based on https://redis.io/commands/incr#pattern-rate-limiter-1 app.use(async (req, res, next) => { - const isIPBlocked = await redis.get(`BLOCKED_${req.ip}`); - - if (isIPBlocked) { - res.status(429).send("Too many requests - try again tomorrow"); - return; - } - let redisIncr: number; try { redisIncr = await redis.incr(req.ip); @@ -82,17 +75,7 @@ export function buildServer() { throw error; } if (redisIncr > 10) { - const today = new Date(); - const tomorrow = new Date(today); - tomorrow.setDate(tomorrow.getDate() + 1); - tomorrow.setHours(0, 0, 0, 0); - await redis.set(`BLOCKED_${req.ip}`, tomorrow.toISOString()); - await redis.expireat( - `BLOCKED_${req.ip}`, - Math.floor(tomorrow.getTime() / 1000) - ); - console.log("Blocked the IP Address:", req.ip); - res.status(429).send("Too many requests - try again tomorrow"); + res.status(429).send("Too many requests - try again later"); return; } await redis.expire(req.ip, 10);