@upstash/redis 1.3.3 → 1.4.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/.releaserc ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "branches": [
3
+ {
4
+ "name": "release"
5
+ },
6
+ {
7
+ "name": "main",
8
+ "channel": "next",
9
+ "prerelease": "next"
10
+ }
11
+ ],
12
+ "dryRun": false,
13
+ "ci": true
14
+ }
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)
@@ -23,6 +23,23 @@ See
23
23
  [the list of APIs](https://docs.upstash.com/features/restapi#rest---redis-api-compatibility)
24
24
  supported.
25
25
 
26
+ ## Upgrading to v1.4.0 **(ReferenceError: fetch is not defined)**
27
+
28
+ If you are running on nodejs v17 and earlier, you need to manually provide a
29
+ `fetch` polyfill. The simplest way is using `isomorphic-fetch`
30
+
31
+ ```bash
32
+ npm install isomorphic-fetch
33
+ ```
34
+
35
+ ```typescript
36
+ import "isomorphic-fetch";
37
+ import { Redis } from "@upstash/redis";
38
+ ```
39
+
40
+ `fetch` is natively supported in node18 as well as all major platforms: Vercel,
41
+ Netlify, Deno, Fastly etc. and you do not need to do anything.
42
+
26
43
  ## Upgrading from v0.2.0?
27
44
 
28
45
  Please read the
@@ -336,3 +353,6 @@ the url and token
336
353
  ```sh
337
354
  UPSTASH_REDIS_REST_URL=".." UPSTASH_REDIS_REST_TOKEN=".." deno test -A
338
355
  ```
356
+
357
+ ```
358
+ ```
@@ -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}` },
@@ -1,11 +1,6 @@
1
1
  // deno-lint-ignore-file
2
2
  import * as core from "../pkg/redis.js";
3
3
  import { UpstashError } from "../pkg/error.js";
4
- // @ts-ignore Deno can't compile
5
- // import https from "https";
6
- // @ts-ignore Deno can't compile
7
- // import http from "http";
8
- import "isomorphic-fetch";
9
4
  /**
10
5
  * Serverless redis client for upstash.
11
6
  */
@@ -15,6 +10,16 @@ export class Redis extends core.Redis {
15
10
  super(configOrRequester);
16
11
  return;
17
12
  }
13
+ if (configOrRequester.url.startsWith(" ") ||
14
+ configOrRequester.url.endsWith(" ") ||
15
+ /\r|\n/.test(configOrRequester.url)) {
16
+ console.warn("The redis url contains whitespace or newline, which can cause errors!");
17
+ }
18
+ if (configOrRequester.token.startsWith(" ") ||
19
+ configOrRequester.token.endsWith(" ") ||
20
+ /\r|\n/.test(configOrRequester.token)) {
21
+ console.warn("The redis token contains whitespace or newline, which can cause errors!");
22
+ }
18
23
  const client = defaultRequester({
19
24
  baseUrl: configOrRequester.url,
20
25
  headers: { authorization: `Bearer ${configOrRequester.token}` },
package/package.json CHANGED
@@ -3,7 +3,6 @@
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",
7
6
  "description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
8
7
  "repository": {
9
8
  "type": "git",
@@ -27,10 +26,6 @@
27
26
  "http": false,
28
27
  "https": false
29
28
  },
30
- "dependencies": {
31
- "encoding": "latest",
32
- "isomorphic-fetch": "^3.0.0"
33
- },
34
29
  "devDependencies": {
35
30
  "@size-limit/preset-small-lib": "latest",
36
31
  "size-limit": "latest"
@@ -82,5 +77,6 @@
82
77
  "require": "./script/platforms/fastly.js",
83
78
  "types": "./types/platforms/fastly.d.ts"
84
79
  }
85
- }
80
+ },
81
+ "version": "1.4.0-next.1"
86
82
  }
@@ -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}` },
@@ -27,11 +27,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.Redis = void 0;
28
28
  const core = __importStar(require("../pkg/redis.js"));
29
29
  const error_js_1 = require("../pkg/error.js");
30
- // @ts-ignore Deno can't compile
31
- // import https from "https";
32
- // @ts-ignore Deno can't compile
33
- // import http from "http";
34
- require("isomorphic-fetch");
35
30
  /**
36
31
  * Serverless redis client for upstash.
37
32
  */
@@ -41,6 +36,16 @@ class Redis extends core.Redis {
41
36
  super(configOrRequester);
42
37
  return;
43
38
  }
39
+ if (configOrRequester.url.startsWith(" ") ||
40
+ configOrRequester.url.endsWith(" ") ||
41
+ /\r|\n/.test(configOrRequester.url)) {
42
+ console.warn("The redis url contains whitespace or newline, which can cause errors!");
43
+ }
44
+ if (configOrRequester.token.startsWith(" ") ||
45
+ configOrRequester.token.endsWith(" ") ||
46
+ /\r|\n/.test(configOrRequester.token)) {
47
+ console.warn("The redis token contains whitespace or newline, which can cause errors!");
48
+ }
44
49
  const client = defaultRequester({
45
50
  baseUrl: configOrRequester.url,
46
51
  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
  *
@@ -1,6 +1,5 @@
1
1
  import * as core from "../pkg/redis.js";
2
2
  import { Requester, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
- import "isomorphic-fetch";
4
3
  export type { Requester, UpstashRequest, UpstashResponse };
5
4
  /**
6
5
  * Connection credentials for upstash redis.