diff --git a/apps/client/package.json b/apps/client/package.json index 8b804c7..4c4e158 100644 --- a/apps/client/package.json +++ b/apps/client/package.json @@ -14,8 +14,8 @@ "@sentry/nextjs": "^7.72.0", "@tanstack/react-query": "^4.35.3", "@upstash/ratelimit": "^0.4.4", + "@upstash/redis": "^1.22.1", "@vercel/analytics": "^1.0.2", - "@vercel/kv": "^0.2.3", "@xstate/react": "^3.2.2", "autoprefixer": "10.4.16", "clsx": "^2.0.0", diff --git a/apps/client/src/middleware.ts b/apps/client/src/middleware.ts index 7acf453..1f18f9a 100644 --- a/apps/client/src/middleware.ts +++ b/apps/client/src/middleware.ts @@ -1,11 +1,13 @@ import { NextRequest, NextResponse } from "next/server"; import { Ratelimit } from "@upstash/ratelimit"; -import { kv } from "@vercel/kv"; +import { Redis } from "@upstash/redis"; const ratelimit = new Ratelimit({ - redis: kv, + redis: Redis.fromEnv(), // 5 requests from the same IP in 10 seconds limiter: Ratelimit.slidingWindow(5, "10 s"), + analytics: true, + prefix: "@upstash/ratelimit", }); export const config = { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9de2bae..0aa1eb8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,12 +35,12 @@ importers: '@upstash/ratelimit': specifier: ^0.4.4 version: 0.4.4 + '@upstash/redis': + specifier: ^1.22.1 + version: 1.22.1 '@vercel/analytics': specifier: ^1.0.2 version: 1.0.2 - '@vercel/kv': - specifier: ^0.2.3 - version: 0.2.3 '@xstate/react': specifier: ^3.2.2 version: 3.2.2(@types/react@18.2.23)(react@18.2.0)(xstate@4.38.2) @@ -2006,14 +2006,6 @@ packages: - encoding dev: false - /@upstash/redis@1.22.0: - resolution: {integrity: sha512-sXoJDoEqqik0HbrNE7yRWckOySEFsoBxfRdCgOqkc0w6py19ZZG50SpGkDDEUXSnBqP8VgGYXhWAiBpqxrt5oA==} - dependencies: - isomorphic-fetch: 3.0.0 - transitivePeerDependencies: - - encoding - dev: false - /@upstash/redis@1.22.1: resolution: {integrity: sha512-7ec2eCMkVxZzuHNb+hPKonX4b/Pu0BdDeSBsEy+jKIqiweXzCs5Dpu9642vJgf57YnEsfwgXnQMVEataarvyeQ==} dependencies: @@ -2026,15 +2018,6 @@ packages: resolution: {integrity: sha512-BZFxVrv24VbNNl5xMxqUojQIegEeXMI6rX3rg1uVLYUEXsuKNBSAEQf4BWEcjQDp/8aYJOj6m8V4PUA3x/cxgg==} dev: false - /@vercel/kv@0.2.3: - resolution: {integrity: sha512-Wq1+EsRBQmvLlcqCZeYVg1MAARWrnETgLe3Sy3UCqG+zg7LThpkt0YHZe1NN3Aj4IRmCKQamotWrLDdEx+ZB3w==} - engines: {node: '>=14.6'} - dependencies: - '@upstash/redis': 1.22.0 - transitivePeerDependencies: - - encoding - dev: false - /@xstate/react@3.2.2(@types/react@18.2.23)(react@18.2.0)(xstate@4.38.2): resolution: {integrity: sha512-feghXWLedyq8JeL13yda3XnHPZKwYDN5HPBLykpLeuNpr9178tQd2/3d0NrH6gSd0sG5mLuLeuD+ck830fgzLQ==} peerDependencies: