@upstash/redis 1.34.1 → 1.34.3-canary

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/fastly.mjs CHANGED
@@ -1 +1,68 @@
1
- import{a as n,b as r,c as t,d as s}from"./chunk-6D54FT2F.mjs";var i=class extends t{constructor(e){if(!e.url)throw new Error("[Upstash Redis] The 'url' property is missing or undefined in your Redis config.");if(!e.token)throw new Error("[Upstash Redis] The 'token' property is missing or undefined in your Redis config.");(e.url.startsWith(" ")||e.url.endsWith(" ")||/\r|\n/.test(e.url))&&console.warn("The redis url contains whitespace or newline, which can cause errors!"),(e.token.startsWith(" ")||e.token.endsWith(" ")||/\r|\n/.test(e.token))&&console.warn("The redis token contains whitespace or newline, which can cause errors!");let o=new r({baseUrl:e.url,retry:e.retry,headers:{authorization:`Bearer ${e.token}`},options:{backend:e.backend},responseEncoding:e.responseEncoding,keepAlive:e.keepAlive,readYourWrites:e.readYourWrites});if(super(o,{automaticDeserialization:e.automaticDeserialization,enableAutoPipelining:e.enableAutoPipelining}),this.addTelemetry({sdk:`@upstash/redis@${s}`,platform:"fastly"}),this.enableAutoPipelining)return this.autoPipeline()}};export{i as Redis,n as errors};
1
+ import {
2
+ HttpClient,
3
+ Redis,
4
+ VERSION,
5
+ error_exports
6
+ } from "./chunk-FC2CKVKB.mjs";
7
+
8
+ // platforms/fastly.ts
9
+ var Redis2 = class extends Redis {
10
+ /**
11
+ * Create a new redis client
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const redis = new Redis({
16
+ * url: "<UPSTASH_REDIS_REST_URL>",
17
+ * token: "<UPSTASH_REDIS_REST_TOKEN>",
18
+ * backend: "upstash-db",
19
+ * });
20
+ * ```
21
+ */
22
+ constructor(config) {
23
+ if (!config.url) {
24
+ console.warn(
25
+ `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
26
+ );
27
+ }
28
+ if (!config.token) {
29
+ console.warn(
30
+ `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
31
+ );
32
+ }
33
+ if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
34
+ console.warn(
35
+ "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
36
+ );
37
+ }
38
+ if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
39
+ console.warn(
40
+ "[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
41
+ );
42
+ }
43
+ const client = new HttpClient({
44
+ baseUrl: config.url,
45
+ retry: config.retry,
46
+ headers: { authorization: `Bearer ${config.token}` },
47
+ options: { backend: config.backend },
48
+ responseEncoding: config.responseEncoding,
49
+ keepAlive: config.keepAlive,
50
+ readYourWrites: config.readYourWrites
51
+ });
52
+ super(client, {
53
+ automaticDeserialization: config.automaticDeserialization,
54
+ enableAutoPipelining: config.enableAutoPipelining
55
+ });
56
+ this.addTelemetry({
57
+ sdk: `@upstash/redis@${VERSION}`,
58
+ platform: "fastly"
59
+ });
60
+ if (this.enableAutoPipelining) {
61
+ return this.autoPipeline();
62
+ }
63
+ }
64
+ };
65
+ export {
66
+ Redis2 as Redis,
67
+ error_exports as errors
68
+ };