File tree Expand file tree Collapse file tree 3 files changed +31
-6
lines changed Expand file tree Collapse file tree 3 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,11 @@ export type RedisConfigCloudflare = {
17
17
/**
18
18
* UPSTASH_REDIS_REST_URL
19
19
*/
20
- url : string ;
20
+ url : string | undefined ;
21
21
/**
22
22
* UPSTASH_REDIS_REST_TOKEN
23
23
*/
24
- token : string ;
24
+ token : string | undefined ;
25
25
/**
26
26
* The signal will allow aborting requests on the fly.
27
27
* For more check: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
@@ -47,6 +47,14 @@ export class Redis extends core.Redis {
47
47
* ```
48
48
*/
49
49
constructor ( config : RedisConfigCloudflare , env ?: Env ) {
50
+ if ( ! config . url ) {
51
+ throw new Error ( `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.` )
52
+ }
53
+
54
+ if ( ! config . token ) {
55
+ throw new Error ( `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.` )
56
+ }
57
+
50
58
if ( config . url . startsWith ( " " ) || config . url . endsWith ( " " ) || / \r | \n / . test ( config . url ) ) {
51
59
console . warn ( "The redis url contains whitespace or newline, which can cause errors!" ) ;
52
60
}
Original file line number Diff line number Diff line change @@ -14,11 +14,11 @@ export type RedisConfigFastly = {
14
14
/**
15
15
* UPSTASH_REDIS_REST_URL
16
16
*/
17
- url : string ;
17
+ url : string | undefined ;
18
18
/**
19
19
* UPSTASH_REDIS_REST_TOKEN
20
20
*/
21
- token : string ;
21
+ token : string | undefined ;
22
22
/**
23
23
* A Request can be forwarded to any backend defined on your service. Backends
24
24
* can be created via the Fastly CLI, API, or web interface, and are
@@ -45,6 +45,14 @@ export class Redis extends core.Redis {
45
45
* ```
46
46
*/
47
47
constructor ( config : RedisConfigFastly ) {
48
+ if ( ! config . url ) {
49
+ throw new Error ( `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.` )
50
+ }
51
+
52
+ if ( ! config . token ) {
53
+ throw new Error ( `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.` )
54
+ }
55
+
48
56
if ( config . url . startsWith ( " " ) || config . url . endsWith ( " " ) || / \r | \n / . test ( config . url ) ) {
49
57
console . warn ( "The redis url contains whitespace or newline, which can cause errors!" ) ;
50
58
}
Original file line number Diff line number Diff line change @@ -27,11 +27,11 @@ export type RedisConfigNodejs = {
27
27
/**
28
28
* UPSTASH_REDIS_REST_URL
29
29
*/
30
- url : string ;
30
+ url : string | undefined ;
31
31
/**
32
32
* UPSTASH_REDIS_REST_TOKEN
33
33
*/
34
- token : string ;
34
+ token : string | undefined ;
35
35
36
36
/**
37
37
* An agent allows you to reuse connections to reduce latency for multiple sequential requests.
@@ -98,6 +98,15 @@ export class Redis extends core.Redis {
98
98
super ( configOrRequester ) ;
99
99
return ;
100
100
}
101
+
102
+ if ( ! configOrRequester . url ) {
103
+ throw new Error ( `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.` )
104
+ }
105
+
106
+ if ( ! configOrRequester . token ) {
107
+ throw new Error ( `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.` )
108
+ }
109
+
101
110
if (
102
111
configOrRequester . url . startsWith ( " " ) ||
103
112
configOrRequester . url . endsWith ( " " ) ||
You can’t perform that action at this time.
0 commit comments