@upstash/redis 1.34.2 → 1.34.3-canary-2

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.
@@ -19,7 +19,7 @@ var UpstashError = class extends Error {
19
19
  var UrlError = class extends Error {
20
20
  constructor(url) {
21
21
  super(
22
- `Upstash Redis client was passed an invalid URL. You should pass the URL together with https. Received: "${url}". `
22
+ `Upstash Redis client was passed an invalid URL. You should pass a URL starting with https. Received: "${url}". `
23
23
  );
24
24
  this.name = "UrlError";
25
25
  }
@@ -32,6 +32,7 @@ var HttpClient = class {
32
32
  options;
33
33
  readYourWrites;
34
34
  upstashSyncToken = "";
35
+ hasCredentials;
35
36
  retry;
36
37
  constructor(config) {
37
38
  this.options = {
@@ -47,13 +48,14 @@ var HttpClient = class {
47
48
  this.readYourWrites = config.readYourWrites ?? true;
48
49
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
49
50
  const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
50
- if (!urlRegex.test(this.baseUrl)) {
51
+ if (this.baseUrl && !urlRegex.test(this.baseUrl)) {
51
52
  throw new UrlError(this.baseUrl);
52
53
  }
53
54
  this.headers = {
54
55
  "Content-Type": "application/json",
55
56
  ...config.headers
56
57
  };
58
+ this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
57
59
  if (this.options.responseEncoding === "base64") {
58
60
  this.headers["Upstash-Encoding"] = "base64";
59
61
  }
@@ -85,6 +87,11 @@ var HttpClient = class {
85
87
  */
86
88
  backend: this.options.backend
87
89
  };
90
+ if (!this.hasCredentials) {
91
+ throw new Error(
92
+ "[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
93
+ );
94
+ }
88
95
  if (this.readYourWrites) {
89
96
  const newHeader = this.upstashSyncToken;
90
97
  this.headers["upstash-sync-token"] = newHeader;
@@ -3793,7 +3800,7 @@ var Redis = class {
3793
3800
  };
3794
3801
 
3795
3802
  // version.ts
3796
- var VERSION = "v1.34.2";
3803
+ var VERSION = "1.34.3-canary-2";
3797
3804
 
3798
3805
  export {
3799
3806
  error_exports,
package/cloudflare.js CHANGED
@@ -50,7 +50,7 @@ var UpstashError = class extends Error {
50
50
  var UrlError = class extends Error {
51
51
  constructor(url) {
52
52
  super(
53
- `Upstash Redis client was passed an invalid URL. You should pass the URL together with https. Received: "${url}". `
53
+ `Upstash Redis client was passed an invalid URL. You should pass a URL starting with https. Received: "${url}". `
54
54
  );
55
55
  this.name = "UrlError";
56
56
  }
@@ -63,6 +63,7 @@ var HttpClient = class {
63
63
  options;
64
64
  readYourWrites;
65
65
  upstashSyncToken = "";
66
+ hasCredentials;
66
67
  retry;
67
68
  constructor(config) {
68
69
  this.options = {
@@ -78,13 +79,14 @@ var HttpClient = class {
78
79
  this.readYourWrites = config.readYourWrites ?? true;
79
80
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
80
81
  const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
81
- if (!urlRegex.test(this.baseUrl)) {
82
+ if (this.baseUrl && !urlRegex.test(this.baseUrl)) {
82
83
  throw new UrlError(this.baseUrl);
83
84
  }
84
85
  this.headers = {
85
86
  "Content-Type": "application/json",
86
87
  ...config.headers
87
88
  };
89
+ this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
88
90
  if (this.options.responseEncoding === "base64") {
89
91
  this.headers["Upstash-Encoding"] = "base64";
90
92
  }
@@ -116,6 +118,11 @@ var HttpClient = class {
116
118
  */
117
119
  backend: this.options.backend
118
120
  };
121
+ if (!this.hasCredentials) {
122
+ throw new Error(
123
+ "[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
124
+ );
125
+ }
119
126
  if (this.readYourWrites) {
120
127
  const newHeader = this.upstashSyncToken;
121
128
  this.headers["upstash-sync-token"] = newHeader;
@@ -3824,7 +3831,7 @@ var Redis = class {
3824
3831
  };
3825
3832
 
3826
3833
  // version.ts
3827
- var VERSION = "v1.34.2";
3834
+ var VERSION = "1.34.3-canary-2";
3828
3835
 
3829
3836
  // platforms/cloudflare.ts
3830
3837
  var Redis2 = class _Redis extends Redis {
@@ -3841,20 +3848,22 @@ var Redis2 = class _Redis extends Redis {
3841
3848
  */
3842
3849
  constructor(config, env) {
3843
3850
  if (!config.url) {
3844
- throw new Error(
3851
+ console.warn(
3845
3852
  `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
3846
3853
  );
3854
+ } else if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
3855
+ console.warn(
3856
+ "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
3857
+ );
3847
3858
  }
3848
3859
  if (!config.token) {
3849
- throw new Error(
3860
+ console.warn(
3850
3861
  `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
3851
3862
  );
3852
- }
3853
- if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
3854
- console.warn("The redis url contains whitespace or newline, which can cause errors!");
3855
- }
3856
- if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
3857
- console.warn("The redis token contains whitespace or newline, which can cause errors!");
3863
+ } else if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
3864
+ console.warn(
3865
+ "[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
3866
+ );
3858
3867
  }
3859
3868
  const client = new HttpClient({
3860
3869
  retry: config.retry,
@@ -3894,13 +3903,13 @@ var Redis2 = class _Redis extends Redis {
3894
3903
  const url = env?.UPSTASH_REDIS_REST_URL ?? UPSTASH_REDIS_REST_URL;
3895
3904
  const token = env?.UPSTASH_REDIS_REST_TOKEN ?? UPSTASH_REDIS_REST_TOKEN;
3896
3905
  if (!url) {
3897
- throw new Error(
3898
- "Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`"
3906
+ console.warn(
3907
+ "[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`"
3899
3908
  );
3900
3909
  }
3901
3910
  if (!token) {
3902
- throw new Error(
3903
- "Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`"
3911
+ console.warn(
3912
+ "[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`"
3904
3913
  );
3905
3914
  }
3906
3915
  return new _Redis({ ...opts, url, token }, env);
package/cloudflare.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Redis,
4
4
  VERSION,
5
5
  error_exports
6
- } from "./chunk-3XV7NWGI.mjs";
6
+ } from "./chunk-2YMDVZBQ.mjs";
7
7
 
8
8
  // platforms/cloudflare.ts
9
9
  var Redis2 = class _Redis extends Redis {
@@ -20,20 +20,22 @@ var Redis2 = class _Redis extends Redis {
20
20
  */
21
21
  constructor(config, env) {
22
22
  if (!config.url) {
23
- throw new Error(
23
+ console.warn(
24
24
  `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
25
25
  );
26
+ } else if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
27
+ console.warn(
28
+ "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
29
+ );
26
30
  }
27
31
  if (!config.token) {
28
- throw new Error(
32
+ console.warn(
29
33
  `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
30
34
  );
31
- }
32
- if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
33
- console.warn("The redis url contains whitespace or newline, which can cause errors!");
34
- }
35
- if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
36
- console.warn("The redis token contains whitespace or newline, which can cause errors!");
35
+ } else if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
36
+ console.warn(
37
+ "[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
38
+ );
37
39
  }
38
40
  const client = new HttpClient({
39
41
  retry: config.retry,
@@ -73,13 +75,13 @@ var Redis2 = class _Redis extends Redis {
73
75
  const url = env?.UPSTASH_REDIS_REST_URL ?? UPSTASH_REDIS_REST_URL;
74
76
  const token = env?.UPSTASH_REDIS_REST_TOKEN ?? UPSTASH_REDIS_REST_TOKEN;
75
77
  if (!url) {
76
- throw new Error(
77
- "Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`"
78
+ console.warn(
79
+ "[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`"
78
80
  );
79
81
  }
80
82
  if (!token) {
81
- throw new Error(
82
- "Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`"
83
+ console.warn(
84
+ "[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`"
83
85
  );
84
86
  }
85
87
  return new _Redis({ ...opts, url, token }, env);
package/fastly.js CHANGED
@@ -50,7 +50,7 @@ var UpstashError = class extends Error {
50
50
  var UrlError = class extends Error {
51
51
  constructor(url) {
52
52
  super(
53
- `Upstash Redis client was passed an invalid URL. You should pass the URL together with https. Received: "${url}". `
53
+ `Upstash Redis client was passed an invalid URL. You should pass a URL starting with https. Received: "${url}". `
54
54
  );
55
55
  this.name = "UrlError";
56
56
  }
@@ -63,6 +63,7 @@ var HttpClient = class {
63
63
  options;
64
64
  readYourWrites;
65
65
  upstashSyncToken = "";
66
+ hasCredentials;
66
67
  retry;
67
68
  constructor(config) {
68
69
  this.options = {
@@ -78,13 +79,14 @@ var HttpClient = class {
78
79
  this.readYourWrites = config.readYourWrites ?? true;
79
80
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
80
81
  const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
81
- if (!urlRegex.test(this.baseUrl)) {
82
+ if (this.baseUrl && !urlRegex.test(this.baseUrl)) {
82
83
  throw new UrlError(this.baseUrl);
83
84
  }
84
85
  this.headers = {
85
86
  "Content-Type": "application/json",
86
87
  ...config.headers
87
88
  };
89
+ this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
88
90
  if (this.options.responseEncoding === "base64") {
89
91
  this.headers["Upstash-Encoding"] = "base64";
90
92
  }
@@ -116,6 +118,11 @@ var HttpClient = class {
116
118
  */
117
119
  backend: this.options.backend
118
120
  };
121
+ if (!this.hasCredentials) {
122
+ throw new Error(
123
+ "[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
124
+ );
125
+ }
119
126
  if (this.readYourWrites) {
120
127
  const newHeader = this.upstashSyncToken;
121
128
  this.headers["upstash-sync-token"] = newHeader;
@@ -3824,7 +3831,7 @@ var Redis = class {
3824
3831
  };
3825
3832
 
3826
3833
  // version.ts
3827
- var VERSION = "v1.34.2";
3834
+ var VERSION = "1.34.3-canary-2";
3828
3835
 
3829
3836
  // platforms/fastly.ts
3830
3837
  var Redis2 = class extends Redis {
@@ -3842,20 +3849,22 @@ var Redis2 = class extends Redis {
3842
3849
  */
3843
3850
  constructor(config) {
3844
3851
  if (!config.url) {
3845
- throw new Error(
3852
+ console.warn(
3846
3853
  `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
3847
3854
  );
3855
+ } else if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
3856
+ console.warn(
3857
+ "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
3858
+ );
3848
3859
  }
3849
3860
  if (!config.token) {
3850
- throw new Error(
3861
+ console.warn(
3851
3862
  `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
3852
3863
  );
3853
- }
3854
- if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
3855
- console.warn("The redis url contains whitespace or newline, which can cause errors!");
3856
- }
3857
- if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
3858
- console.warn("The redis token contains whitespace or newline, which can cause errors!");
3864
+ } else if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
3865
+ console.warn(
3866
+ "[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
3867
+ );
3859
3868
  }
3860
3869
  const client = new HttpClient({
3861
3870
  baseUrl: config.url,
package/fastly.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Redis,
4
4
  VERSION,
5
5
  error_exports
6
- } from "./chunk-3XV7NWGI.mjs";
6
+ } from "./chunk-2YMDVZBQ.mjs";
7
7
 
8
8
  // platforms/fastly.ts
9
9
  var Redis2 = class extends Redis {
@@ -21,20 +21,22 @@ var Redis2 = class extends Redis {
21
21
  */
22
22
  constructor(config) {
23
23
  if (!config.url) {
24
- throw new Error(
24
+ console.warn(
25
25
  `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
26
26
  );
27
+ } else if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
28
+ console.warn(
29
+ "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
30
+ );
27
31
  }
28
32
  if (!config.token) {
29
- throw new Error(
33
+ console.warn(
30
34
  `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
31
35
  );
32
- }
33
- if (config.url.startsWith(" ") || config.url.endsWith(" ") || /\r|\n/.test(config.url)) {
34
- console.warn("The redis url contains whitespace or newline, which can cause errors!");
35
- }
36
- if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
37
- console.warn("The redis token contains whitespace or newline, which can cause errors!");
36
+ } else if (config.token.startsWith(" ") || config.token.endsWith(" ") || /\r|\n/.test(config.token)) {
37
+ console.warn(
38
+ "[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
39
+ );
38
40
  }
39
41
  const client = new HttpClient({
40
42
  baseUrl: config.url,
package/nodejs.js CHANGED
@@ -50,7 +50,7 @@ var UpstashError = class extends Error {
50
50
  var UrlError = class extends Error {
51
51
  constructor(url) {
52
52
  super(
53
- `Upstash Redis client was passed an invalid URL. You should pass the URL together with https. Received: "${url}". `
53
+ `Upstash Redis client was passed an invalid URL. You should pass a URL starting with https. Received: "${url}". `
54
54
  );
55
55
  this.name = "UrlError";
56
56
  }
@@ -63,6 +63,7 @@ var HttpClient = class {
63
63
  options;
64
64
  readYourWrites;
65
65
  upstashSyncToken = "";
66
+ hasCredentials;
66
67
  retry;
67
68
  constructor(config) {
68
69
  this.options = {
@@ -78,13 +79,14 @@ var HttpClient = class {
78
79
  this.readYourWrites = config.readYourWrites ?? true;
79
80
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
80
81
  const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
81
- if (!urlRegex.test(this.baseUrl)) {
82
+ if (this.baseUrl && !urlRegex.test(this.baseUrl)) {
82
83
  throw new UrlError(this.baseUrl);
83
84
  }
84
85
  this.headers = {
85
86
  "Content-Type": "application/json",
86
87
  ...config.headers
87
88
  };
89
+ this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
88
90
  if (this.options.responseEncoding === "base64") {
89
91
  this.headers["Upstash-Encoding"] = "base64";
90
92
  }
@@ -116,6 +118,11 @@ var HttpClient = class {
116
118
  */
117
119
  backend: this.options.backend
118
120
  };
121
+ if (!this.hasCredentials) {
122
+ throw new Error(
123
+ "[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
124
+ );
125
+ }
119
126
  if (this.readYourWrites) {
120
127
  const newHeader = this.upstashSyncToken;
121
128
  this.headers["upstash-sync-token"] = newHeader;
@@ -3824,7 +3831,7 @@ var Redis = class {
3824
3831
  };
3825
3832
 
3826
3833
  // version.ts
3827
- var VERSION = "v1.34.2";
3834
+ var VERSION = "1.34.3-canary-2";
3828
3835
 
3829
3836
  // platforms/nodejs.ts
3830
3837
  if (typeof atob === "undefined") {
@@ -3854,26 +3861,27 @@ var Redis2 = class _Redis extends Redis {
3854
3861
  return;
3855
3862
  }
3856
3863
  if (!configOrRequester.url) {
3857
- throw new Error(
3864
+ console.warn(
3858
3865
  `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
3859
3866
  );
3867
+ } else if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
3868
+ console.warn(
3869
+ "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
3870
+ );
3860
3871
  }
3861
3872
  if (!configOrRequester.token) {
3862
- throw new Error(
3873
+ console.warn(
3863
3874
  `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
3864
3875
  );
3865
- }
3866
- if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
3867
- console.warn("The redis url contains whitespace or newline, which can cause errors!");
3868
- }
3869
- if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
3870
- console.warn("The redis token contains whitespace or newline, which can cause errors!");
3876
+ } else if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
3877
+ console.warn(
3878
+ "[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
3879
+ );
3871
3880
  }
3872
3881
  const client = new HttpClient({
3873
3882
  baseUrl: configOrRequester.url,
3874
3883
  retry: configOrRequester.retry,
3875
3884
  headers: { authorization: `Bearer ${configOrRequester.token}` },
3876
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
3877
3885
  agent: configOrRequester.agent,
3878
3886
  responseEncoding: configOrRequester.responseEncoding,
3879
3887
  cache: configOrRequester.cache ?? "no-store",
@@ -3911,16 +3919,18 @@ var Redis2 = class _Redis extends Redis {
3911
3919
  static fromEnv(config) {
3912
3920
  if (process.env === void 0) {
3913
3921
  throw new TypeError(
3914
- 'Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
3922
+ '[Upstash Redis] Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
3915
3923
  );
3916
3924
  }
3917
3925
  const url = process.env.UPSTASH_REDIS_REST_URL;
3918
3926
  if (!url) {
3919
- throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
3927
+ console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
3920
3928
  }
3921
3929
  const token = process.env.UPSTASH_REDIS_REST_TOKEN;
3922
3930
  if (!token) {
3923
- throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
3931
+ console.warn(
3932
+ "[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
3933
+ );
3924
3934
  }
3925
3935
  return new _Redis({ ...config, url, token });
3926
3936
  }
package/nodejs.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Redis,
4
4
  VERSION,
5
5
  error_exports
6
- } from "./chunk-3XV7NWGI.mjs";
6
+ } from "./chunk-2YMDVZBQ.mjs";
7
7
 
8
8
  // platforms/nodejs.ts
9
9
  if (typeof atob === "undefined") {
@@ -33,26 +33,27 @@ var Redis2 = class _Redis extends Redis {
33
33
  return;
34
34
  }
35
35
  if (!configOrRequester.url) {
36
- throw new Error(
36
+ console.warn(
37
37
  `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
38
38
  );
39
+ } else if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
40
+ console.warn(
41
+ "[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
42
+ );
39
43
  }
40
44
  if (!configOrRequester.token) {
41
- throw new Error(
45
+ console.warn(
42
46
  `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
43
47
  );
44
- }
45
- if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
46
- console.warn("The redis url contains whitespace or newline, which can cause errors!");
47
- }
48
- if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
49
- console.warn("The redis token contains whitespace or newline, which can cause errors!");
48
+ } else if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
49
+ console.warn(
50
+ "[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
51
+ );
50
52
  }
51
53
  const client = new HttpClient({
52
54
  baseUrl: configOrRequester.url,
53
55
  retry: configOrRequester.retry,
54
56
  headers: { authorization: `Bearer ${configOrRequester.token}` },
55
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
56
57
  agent: configOrRequester.agent,
57
58
  responseEncoding: configOrRequester.responseEncoding,
58
59
  cache: configOrRequester.cache ?? "no-store",
@@ -90,16 +91,18 @@ var Redis2 = class _Redis extends Redis {
90
91
  static fromEnv(config) {
91
92
  if (process.env === void 0) {
92
93
  throw new TypeError(
93
- 'Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
94
+ '[Upstash Redis] Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
94
95
  );
95
96
  }
96
97
  const url = process.env.UPSTASH_REDIS_REST_URL;
97
98
  if (!url) {
98
- throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
99
+ console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
99
100
  }
100
101
  const token = process.env.UPSTASH_REDIS_REST_TOKEN;
101
102
  if (!token) {
102
- throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
103
+ console.warn(
104
+ "[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
105
+ );
103
106
  }
104
107
  return new _Redis({ ...config, url, token });
105
108
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@upstash/redis","version":"v1.34.2","main":"./nodejs.js","module":"./nodejs.mjs","types":"./nodejs.d.ts","exports":{".":{"import":"./nodejs.mjs","require":"./nodejs.js"},"./node":{"import":"./nodejs.mjs","require":"./nodejs.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./cloudflare.js":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./cloudflare.mjs":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./fastly":{"import":"./fastly.mjs","require":"./fastly.js"},"./fastly.js":{"import":"./fastly.mjs","require":"./fastly.js"},"./fastly.mjs":{"import":"./fastly.mjs","require":"./fastly.js"}},"description":"An HTTP/REST based Redis client built on top of Upstash REST API.","repository":{"type":"git","url":"git+https://github.com/upstash/upstash-redis.git"},"keywords":["redis","database","serverless","edge","upstash"],"files":["./*"],"scripts":{"build":"tsup && cp package.json README.md LICENSE dist/","test":"bun test pkg","fmt":"prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"","lint":"eslint \"**/*.{js,ts,tsx}\" --quiet --fix","format":"prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"","format:check":"prettier --check \"**/*.{ts,tsx,js,jsx,json,md}\"","lint:fix":"eslint . -c .ts,.tsx,.js,.jsx --fix","commit":"cz","lint:format":"bun run lint:fix && bun run format","check-exports":"bun run build && cd dist && attw -P"},"author":"Andreas Thomas <dev@chronark.com>","license":"MIT","bugs":{"url":"https://github.com/upstash/upstash-redis/issues"},"homepage":"https://github.com/upstash/upstash-redis#readme","devDependencies":{"@biomejs/biome":"latest","@commitlint/cli":"^19.3.0","@commitlint/config-conventional":"^19.2.2","@types/crypto-js":"^4.1.3","@typescript-eslint/eslint-plugin":"8.4.0","@typescript-eslint/parser":"8.4.0","bun-types":"1.0.33","eslint":"9.10.0","eslint-plugin-unicorn":"55.0.0","husky":"^9.1.1","prettier":"^3.3.3","tsup":"^8.2.3","typescript":"latest"},"dependencies":{"crypto-js":"^4.2.0"}}
1
+ {"name":"@upstash/redis","version":"1.34.3-canary-2","main":"./nodejs.js","module":"./nodejs.mjs","types":"./nodejs.d.ts","exports":{".":{"import":"./nodejs.mjs","require":"./nodejs.js"},"./node":{"import":"./nodejs.mjs","require":"./nodejs.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./cloudflare.js":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./cloudflare.mjs":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./fastly":{"import":"./fastly.mjs","require":"./fastly.js"},"./fastly.js":{"import":"./fastly.mjs","require":"./fastly.js"},"./fastly.mjs":{"import":"./fastly.mjs","require":"./fastly.js"}},"description":"An HTTP/REST based Redis client built on top of Upstash REST API.","repository":{"type":"git","url":"git+https://github.com/upstash/upstash-redis.git"},"keywords":["redis","database","serverless","edge","upstash"],"files":["./*"],"scripts":{"build":"tsup && cp package.json README.md LICENSE dist/","test":"bun test pkg","fmt":"prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"","lint":"eslint \"**/*.{js,ts,tsx}\" --quiet --fix","format":"prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"","format:check":"prettier --check \"**/*.{ts,tsx,js,jsx,json,md}\"","lint:fix":"eslint . -c .ts,.tsx,.js,.jsx --fix","commit":"cz","lint:format":"bun run lint:fix && bun run format","check-exports":"bun run build && cd dist && attw -P"},"author":"Andreas Thomas <dev@chronark.com>","license":"MIT","bugs":{"url":"https://github.com/upstash/upstash-redis/issues"},"homepage":"https://github.com/upstash/upstash-redis#readme","devDependencies":{"@biomejs/biome":"latest","@commitlint/cli":"^19.3.0","@commitlint/config-conventional":"^19.2.2","@types/crypto-js":"^4.1.3","@typescript-eslint/eslint-plugin":"8.4.0","@typescript-eslint/parser":"8.4.0","bun-types":"1.0.33","eslint":"9.10.0","eslint-plugin-unicorn":"55.0.0","husky":"^9.1.1","prettier":"^3.3.3","tsup":"^8.2.3","typescript":"latest"},"dependencies":{"crypto-js":"^4.2.0"}}