From c3318abb1f3ba37d26fa35941c6ffdd02efe3e57 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Tue, 25 Nov 2025 21:55:35 +0300 Subject: [PATCH 1/2] fix: add Requester type declaration --- platforms/nodejs.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platforms/nodejs.ts b/platforms/nodejs.ts index 95d9dc41..201c0db5 100644 --- a/platforms/nodejs.ts +++ b/platforms/nodejs.ts @@ -78,6 +78,11 @@ export class Redis extends core.Redis { */ constructor(config: RedisConfigNodejs); + /** + * Create a new redis client by providing a custom `Requester` implementation + */ + constructor(requester: Requester); + /** * Create a new redis client by providing a custom `Requester` implementation * From 1d1cfb13a8f932d9008697e6b89c2c340df5dd46 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Tue, 25 Nov 2025 22:08:21 +0300 Subject: [PATCH 2/2] fix: add route with custom requester to check it in ci --- .../app/api/custom-requester/route.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/vercel-functions-app-router/app/api/custom-requester/route.ts diff --git a/examples/vercel-functions-app-router/app/api/custom-requester/route.ts b/examples/vercel-functions-app-router/app/api/custom-requester/route.ts new file mode 100644 index 00000000..74455468 --- /dev/null +++ b/examples/vercel-functions-app-router/app/api/custom-requester/route.ts @@ -0,0 +1,25 @@ +import { Redis, Requester, UpstashResponse } from "@upstash/redis"; + +/** + * it's possible to create a Redis client with a custom requester + * implementation. This can be useful if you want to modify the + * request/response behavior, add custom logging, or integrate with + * other libraries. + * + * In this example, we create a simple custom requester that logs + * the request options and returns a mock response. + */ + +const requester = { + request: async (opts) => { + console.log("Custom requester called with:", opts); + return { result: "custom response" } as UpstashResponse; + }, +} satisfies Requester + +const redis = new Redis(requester) + +export async function GET() { + const response = await redis.get("mykey"); + return new Response(JSON.stringify({ response })); +} \ No newline at end of file