@upstash/redis 1.35.0-canary → 1.35.0

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.
@@ -3,7 +3,7 @@ import {
3
3
  Redis,
4
4
  VERSION,
5
5
  error_exports
6
- } from "./chunk-Q4ZBDYYE.mjs";
6
+ } from "./chunk-QZ3IMTW7.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
- const url = process.env.UPSTASH_REDIS_REST_URL;
97
+ const url = process.env.UPSTASH_REDIS_REST_URL || process.env.KV_REST_API_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
- const token = process.env.UPSTASH_REDIS_REST_TOKEN;
101
+ const token = process.env.UPSTASH_REDIS_REST_TOKEN || process.env.KV_REST_API_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.35.0-canary", "main": "./dist/nodejs.js", "module": "./dist/nodejs.mjs", "types": "./dist/nodejs.d.ts", "exports": { ".": { "import": "./dist/nodejs.mjs", "require": "./dist/nodejs.js" }, "./node": { "import": "./dist/nodejs.mjs", "require": "./dist/nodejs.js" }, "./node.js": { "import": "./dist/nodejs.mjs", "require": "./dist/nodejs.js" }, "./node.mjs": { "import": "./dist/nodejs.mjs", "require": "./dist/nodejs.js" }, "./cloudflare": { "import": "./dist/cloudflare.mjs", "require": "./dist/cloudflare.js" }, "./cloudflare.js": { "import": "./dist/cloudflare.mjs", "require": "./dist/cloudflare.js" }, "./cloudflare.mjs": { "import": "./dist/cloudflare.mjs", "require": "./dist/cloudflare.js" }, "./fastly": { "import": "./dist/fastly.mjs", "require": "./dist/fastly.js" }, "./fastly.js": { "import": "./dist/fastly.mjs", "require": "./dist/fastly.js" }, "./fastly.mjs": { "import": "./dist/fastly.mjs", "require": "./dist/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": [ "dist" ], "scripts": { "build": "tsup", "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" }, "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":"v1.35.0","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"}}