@upstash/redis 1.3.3-alpha.1 → 1.3.5

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Upstash Redis
2
2
 
3
- An HTTP/REST based Redis client built on top of
4
- [Upstash REST API](https://docs.upstash.com/features/restapi).
3
+ `@upstash/redis` is an HTTP/REST based Redis client for typescript, built on top
4
+ of [Upstash REST API](https://docs.upstash.com/features/restapi).
5
5
 
6
6
  [![Tests](https://github.com/upstash/upstash-redis/actions/workflows/tests.yaml/badge.svg)](https://github.com/upstash/upstash-redis/actions/workflows/tests.yaml)
7
7
  ![npm (scoped)](https://img.shields.io/npm/v/@upstash/redis)
@@ -16,6 +16,16 @@ export class Redis extends core.Redis {
16
16
  * ```
17
17
  */
18
18
  constructor(config) {
19
+ if (config.url.startsWith(" ") ||
20
+ config.url.endsWith(" ") ||
21
+ /\r|\n/.test(config.url)) {
22
+ console.warn("The redis url contains whitespace or newline, which can cause errors!");
23
+ }
24
+ if (config.token.startsWith(" ") ||
25
+ config.token.endsWith(" ") ||
26
+ /\r|\n/.test(config.token)) {
27
+ console.warn("The redis token contains whitespace or newline, which can cause errors!");
28
+ }
19
29
  const client = defaultRequester({
20
30
  baseUrl: config.url,
21
31
  headers: { authorization: `Bearer ${config.token}` },
@@ -17,6 +17,16 @@ export class Redis extends core.Redis {
17
17
  * ```
18
18
  */
19
19
  constructor(config) {
20
+ if (config.url.startsWith(" ") ||
21
+ config.url.endsWith(" ") ||
22
+ /\r|\n/.test(config.url)) {
23
+ console.warn("The redis url contains whitespace or newline, which can cause errors!");
24
+ }
25
+ if (config.token.startsWith(" ") ||
26
+ config.token.endsWith(" ") ||
27
+ /\r|\n/.test(config.token)) {
28
+ console.warn("The redis token contains whitespace or newline, which can cause errors!");
29
+ }
20
30
  const client = defaultRequester({
21
31
  baseUrl: config.url,
22
32
  headers: { authorization: `Bearer ${config.token}` },
@@ -15,6 +15,16 @@ export class Redis extends core.Redis {
15
15
  super(configOrRequester);
16
16
  return;
17
17
  }
18
+ if (configOrRequester.url.startsWith(" ") ||
19
+ configOrRequester.url.endsWith(" ") ||
20
+ /\r|\n/.test(configOrRequester.url)) {
21
+ console.warn("The redis url contains whitespace or newline, which can cause errors!");
22
+ }
23
+ if (configOrRequester.token.startsWith(" ") ||
24
+ configOrRequester.token.endsWith(" ") ||
25
+ /\r|\n/.test(configOrRequester.token)) {
26
+ console.warn("The redis token contains whitespace or newline, which can cause errors!");
27
+ }
18
28
  const client = defaultRequester({
19
29
  baseUrl: configOrRequester.url,
20
30
  headers: { authorization: `Bearer ${configOrRequester.token}` },
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./script/platforms/nodejs.js",
4
4
  "types": "./types/platforms/nodejs.d.ts",
5
5
  "name": "@upstash/redis",
6
- "version": "v1.3.3-alpha.1",
6
+ "version": "v1.3.5",
7
7
  "description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
8
8
  "repository": {
9
9
  "type": "git",
@@ -42,6 +42,16 @@ class Redis extends core.Redis {
42
42
  * ```
43
43
  */
44
44
  constructor(config) {
45
+ if (config.url.startsWith(" ") ||
46
+ config.url.endsWith(" ") ||
47
+ /\r|\n/.test(config.url)) {
48
+ console.warn("The redis url contains whitespace or newline, which can cause errors!");
49
+ }
50
+ if (config.token.startsWith(" ") ||
51
+ config.token.endsWith(" ") ||
52
+ /\r|\n/.test(config.token)) {
53
+ console.warn("The redis token contains whitespace or newline, which can cause errors!");
54
+ }
45
55
  const client = defaultRequester({
46
56
  baseUrl: config.url,
47
57
  headers: { authorization: `Bearer ${config.token}` },
@@ -43,6 +43,16 @@ class Redis extends core.Redis {
43
43
  * ```
44
44
  */
45
45
  constructor(config) {
46
+ if (config.url.startsWith(" ") ||
47
+ config.url.endsWith(" ") ||
48
+ /\r|\n/.test(config.url)) {
49
+ console.warn("The redis url contains whitespace or newline, which can cause errors!");
50
+ }
51
+ if (config.token.startsWith(" ") ||
52
+ config.token.endsWith(" ") ||
53
+ /\r|\n/.test(config.token)) {
54
+ console.warn("The redis token contains whitespace or newline, which can cause errors!");
55
+ }
46
56
  const client = defaultRequester({
47
57
  baseUrl: config.url,
48
58
  headers: { authorization: `Bearer ${config.token}` },
@@ -41,6 +41,16 @@ class Redis extends core.Redis {
41
41
  super(configOrRequester);
42
42
  return;
43
43
  }
44
+ if (configOrRequester.url.startsWith(" ") ||
45
+ configOrRequester.url.endsWith(" ") ||
46
+ /\r|\n/.test(configOrRequester.url)) {
47
+ console.warn("The redis url contains whitespace or newline, which can cause errors!");
48
+ }
49
+ if (configOrRequester.token.startsWith(" ") ||
50
+ configOrRequester.token.endsWith(" ") ||
51
+ /\r|\n/.test(configOrRequester.token)) {
52
+ console.warn("The redis token contains whitespace or newline, which can cause errors!");
53
+ }
44
54
  const client = defaultRequester({
45
55
  baseUrl: configOrRequester.url,
46
56
  headers: { authorization: `Bearer ${configOrRequester.token}` },
@@ -1,4 +1,4 @@
1
- import { DelCommand, ExistsCommand, FlushAllCommand, PingCommand, ScoreMember, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
1
+ import { CommandOptions, DelCommand, ExistsCommand, FlushAllCommand, PingCommand, ScoreMember, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
2
  import { Requester } from "./http.js";
3
3
  import { Pipeline } from "./pipeline.js";
4
4
  import type { CommandArgs } from "./types.js";
@@ -14,8 +14,8 @@ export declare type RedisOptions = {
14
14
  * Serverless redis client for upstash.
15
15
  */
16
16
  export declare class Redis {
17
- private readonly client;
18
- private opts?;
17
+ protected readonly client: Requester;
18
+ protected opts?: CommandOptions<any, any>;
19
19
  /**
20
20
  * Create a new redis client
21
21
  *