Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<any>;
},
} satisfies Requester

const redis = new Redis(requester)

export async function GET() {
const response = await redis.get("mykey");
return new Response(JSON.stringify({ response }));
}
5 changes: 5 additions & 0 deletions platforms/nodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down