@upstash/redis 0.0.0-ci.998046a844b4998e6b7de8c128d5f41be5545cdf-20241002104435 → 0.0.0-ci.9a0f7fcd9dc38c0a4ce2b192f3f9c3542ccc791c-20251125190254

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/nodejs.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Redis,
4
4
  VERSION,
5
5
  error_exports
6
- } from "./chunk-K53GSI5K.mjs";
6
+ } from "./chunk-WTYE7OV3.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",
@@ -62,7 +63,7 @@ var Redis2 = class _Redis extends Redis {
62
63
  });
63
64
  super(client, {
64
65
  automaticDeserialization: configOrRequester.automaticDeserialization,
65
- enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
66
+ enableTelemetry: configOrRequester.enableTelemetry ?? !process.env.UPSTASH_DISABLE_TELEMETRY,
66
67
  latencyLogging: configOrRequester.latencyLogging,
67
68
  enableAutoPipelining: configOrRequester.enableAutoPipelining
68
69
  });
@@ -71,7 +72,7 @@ var Redis2 = class _Redis extends Redis {
71
72
  // @ts-expect-error to silence compiler
72
73
  typeof EdgeRuntime === "string" ? "edge-light" : `node@${process.version}`
73
74
  ),
74
- platform: process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
75
+ platform: process.env.UPSTASH_CONSOLE ? "console" : process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
75
76
  sdk: `@upstash/redis@${VERSION}`
76
77
  });
77
78
  if (this.enableAutoPipelining) {
@@ -84,22 +85,28 @@ var Redis2 = class _Redis extends Redis {
84
85
  * Use this to automatically load connection secrets from your environment
85
86
  * variables. For instance when using the Vercel integration.
86
87
  *
87
- * This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from
88
- * your environment using `process.env`.
88
+ * This tries to load connection details from your environment using `process.env`:
89
+ * - URL: `UPSTASH_REDIS_REST_URL` or fallback to `KV_REST_API_URL`
90
+ * - Token: `UPSTASH_REDIS_REST_TOKEN` or fallback to `KV_REST_API_TOKEN`
91
+ *
92
+ * The fallback variables provide compatibility with Vercel KV and other platforms
93
+ * that may use different naming conventions.
89
94
  */
90
95
  static fromEnv(config) {
91
96
  if (process.env === void 0) {
92
97
  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'
98
+ '[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
99
  );
95
100
  }
96
- const url = process.env.UPSTASH_REDIS_REST_URL;
101
+ const url = process.env.UPSTASH_REDIS_REST_URL || process.env.KV_REST_API_URL;
97
102
  if (!url) {
98
- throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
103
+ console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
99
104
  }
100
- const token = process.env.UPSTASH_REDIS_REST_TOKEN;
105
+ const token = process.env.UPSTASH_REDIS_REST_TOKEN || process.env.KV_REST_API_TOKEN;
101
106
  if (!token) {
102
- throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
107
+ console.warn(
108
+ "[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
109
+ );
103
110
  }
104
111
  return new _Redis({ ...config, url, token });
105
112
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- { "name": "@upstash/redis", "version": "v0.0.0-ci.998046a844b4998e6b7de8c128d5f41be5545cdf-20241002104435", "main": "./nodejs.js", "module": "./nodejs.mjs", "types": "./nodejs.d.ts", "exports": { ".": { "import": "./nodejs.mjs", "require": "./nodejs.js" }, "./node": { "import": "./nodejs.mjs", "require": "./nodejs.js" }, "./node.js": { "import": "./nodejs.mjs", "require": "./nodejs.js" }, "./node.mjs": { "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}\"", "prepare": "husky install", "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":"v0.0.0-ci.9a0f7fcd9dc38c0a4ce2b192f3f9c3542ccc791c-20251125190254","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","@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":{"uncrypto":"^0.1.3"}}