@upstash/redis 1.9.1-next.1 → 1.10.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/pkg/redis.js CHANGED
@@ -28,6 +28,19 @@ export class Redis {
28
28
  writable: true,
29
29
  value: void 0
30
30
  });
31
+ /**
32
+ * Wrap a new middleware around the HTTP client.
33
+ */
34
+ Object.defineProperty(this, "use", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: (middleware) => {
39
+ console.warn("use");
40
+ const makeRequest = this.client.request.bind(this.client);
41
+ this.client.request = (req) => middleware(req, makeRequest);
42
+ }
43
+ });
31
44
  /**
32
45
  * Create a new pipeline that allows you to send requests in bulk.
33
46
  *
package/package.json CHANGED
@@ -97,5 +97,5 @@
97
97
  "types": "./types/platforms/node_with_fetch.d.ts"
98
98
  }
99
99
  },
100
- "version": "1.9.1-next.1"
100
+ "version": "1.10.0-next.1"
101
101
  }
@@ -31,6 +31,19 @@ class Redis {
31
31
  writable: true,
32
32
  value: void 0
33
33
  });
34
+ /**
35
+ * Wrap a new middleware around the HTTP client.
36
+ */
37
+ Object.defineProperty(this, "use", {
38
+ enumerable: true,
39
+ configurable: true,
40
+ writable: true,
41
+ value: (middleware) => {
42
+ console.warn("use");
43
+ const makeRequest = this.client.request.bind(this.client);
44
+ this.client.request = (req) => middleware(req, makeRequest);
45
+ }
46
+ });
34
47
  /**
35
48
  * Create a new pipeline that allows you to send requests in bulk.
36
49
  *
@@ -1,5 +1,5 @@
1
1
  import { CommandOptions, DelCommand, ExistsCommand, FlushAllCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
- import { Requester } from "./http.js";
2
+ import { Requester, UpstashRequest, UpstashResponse } from "./http.js";
3
3
  import { Pipeline } from "./pipeline.js";
4
4
  import type { CommandArgs } from "./types.js";
5
5
  export declare type RedisOptions = {
@@ -14,7 +14,7 @@ export declare type RedisOptions = {
14
14
  * Serverless redis client for upstash.
15
15
  */
16
16
  export declare class Redis {
17
- protected readonly client: Requester;
17
+ protected client: Requester;
18
18
  protected opts?: CommandOptions<any, any>;
19
19
  /**
20
20
  * Create a new redis client
@@ -28,6 +28,10 @@ export declare class Redis {
28
28
  * ```
29
29
  */
30
30
  constructor(client: Requester, opts?: RedisOptions);
31
+ /**
32
+ * Wrap a new middleware around the HTTP client.
33
+ */
34
+ use: <TResult = unknown>(middleware: (r: UpstashRequest, next: <TResult_1 = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult_1>>) => Promise<UpstashResponse<TResult>>) => void;
31
35
  /**
32
36
  * Create a new pipeline that allows you to send requests in bulk.
33
37
  *