@upstash/redis 1.1.0 → 1.2.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.
package/README.md CHANGED
@@ -77,11 +77,26 @@ const redis = new Redis({
77
77
  url: <UPSTASH_REDIS_REST_URL>,
78
78
  token: <UPSTASH_REDIS_REST_TOKEN>,
79
79
  })
80
- // or load directly from env
80
+
81
+
82
+ // or load directly from global env
83
+
84
+ // service worker
81
85
  const redis = Redis.fromEnv()
86
+
87
+
88
+ // module worker
89
+ export default {
90
+ async fetch(request: Request, env: Bindings) {
91
+ const redis = Redis.fromEnv(env)
92
+ // ...
93
+ }
94
+ }
95
+
82
96
  ```
83
97
 
84
- - [Code example](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers)
98
+ - [Code example service worker](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers)
99
+ - [Code example module worker](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers-modules)
85
100
  - [Documentation](https://docs.upstash.com/redis/tutorials/cloudflare_workers_with_redis)
86
101
 
87
102
  #### Fastly
package/cloudflare.d.ts CHANGED
@@ -32,7 +32,10 @@ declare class Redis extends Redis$1 {
32
32
  * ```
33
33
  */
34
34
  constructor(config: RedisConfigCloudflare);
35
- static fromEnv(): Redis;
35
+ static fromEnv(env?: {
36
+ UPSTASH_REDIS_REST_URL: string;
37
+ UPSTASH_REDIS_REST_TOKEN: string;
38
+ }): Redis;
36
39
  }
37
40
 
38
41
  export { Redis, RedisConfigCloudflare };
package/cloudflare.js CHANGED
@@ -1314,9 +1314,10 @@ var Redis2 = class extends Redis {
1314
1314
  });
1315
1315
  super(client);
1316
1316
  }
1317
- static fromEnv() {
1318
- const url = UPSTASH_REDIS_REST_URL;
1319
- const token = UPSTASH_REDIS_REST_TOKEN;
1317
+ static fromEnv(env) {
1318
+ var _a, _b;
1319
+ const url = (_a = env == null ? void 0 : env.UPSTASH_REDIS_REST_URL) != null ? _a : UPSTASH_REDIS_REST_URL;
1320
+ const token = (_b = env == null ? void 0 : env.UPSTASH_REDIS_REST_TOKEN) != null ? _b : UPSTASH_REDIS_REST_TOKEN;
1320
1321
  if (!url) {
1321
1322
  throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`");
1322
1323
  }
package/cloudflare.mjs CHANGED
@@ -18,9 +18,10 @@ var Redis2 = class extends Redis {
18
18
  });
19
19
  super(client);
20
20
  }
21
- static fromEnv() {
22
- const url = UPSTASH_REDIS_REST_URL;
23
- const token = UPSTASH_REDIS_REST_TOKEN;
21
+ static fromEnv(env) {
22
+ var _a, _b;
23
+ const url = (_a = env == null ? void 0 : env.UPSTASH_REDIS_REST_URL) != null ? _a : UPSTASH_REDIS_REST_URL;
24
+ const token = (_b = env == null ? void 0 : env.UPSTASH_REDIS_REST_TOKEN) != null ? _b : UPSTASH_REDIS_REST_TOKEN;
24
25
  if (!url) {
25
26
  throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`");
26
27
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- { "name": "@upstash/redis", "version": "v1.1.0", "engines": { "node": ">=10" }, "description": "An HTTP/REST based Redis client built on top of Upstash REST API.", "main": "./index.js", "module": "./index.mjs", "types": "./index.d.ts", "scripts": { "test": "jest -i", "fmt": "pnpm lint && pnpm prettier --write .", "lint": "eslint --ext .ts --fix --ignore-path .gitignore .", "build": "tsup && cp package.json ./dist/ && pnpm size-limit" }, "repository": { "type": "git", "url": "git+https://github.com/upstash/upstash-redis.git" }, "keywords": [ "redis", "database", "serverless", "edge", "upstash" ], "author": "Andreas Thomas <andreas.thomas@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/upstash-redis/issues" }, "homepage": "https://github.com/upstash/upstash-redis#readme", "directories": { "examples": "examples" }, "devDependencies": { "@jest/globals": "^27.4.6", "@size-limit/preset-small-lib": "^7.0.8", "@trivago/prettier-plugin-sort-imports": "^3.2.0", "@types/jest": "^27.4.0", "@types/node": "^17.0.8", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "dotenv": "^12.0.3", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "jest": "^27.4.7", "prettier": "^2.5.1", "size-limit": "^7.0.8", "ts-jest": "^27.1.3", "tsup": "^5.11.11", "typescript": "^4.5.5" }, "dependencies": { "isomorphic-fetch": "^3.0.0" }, "browser": { "isomorphic-fetch": false }, "size-limit": [ { "path": "dist/index.js", "limit": "5 KB" }, { "path": "dist/index.mjs", "limit": "5 KB" }, { "path": "dist/cloudflare.js", "limit": "5 KB" }, { "path": "dist/cloudflare.mjs", "limit": "5 KB" }, { "path": "dist/nodejs.js", "limit": "5 KB" }, { "path": "dist/nodejs.mjs", "limit": "5 KB" }, { "path": "dist/fastly.js", "limit": "5 KB" }, { "path": "dist/fastly.mjs", "limit": "5 KB" } ] }
1
+ { "name": "@upstash/redis", "version": "v1.2.0", "engines": { "node": ">=10" }, "description": "An HTTP/REST based Redis client built on top of Upstash REST API.", "main": "./index.js", "module": "./index.mjs", "types": "./index.d.ts", "scripts": { "test": "jest -i", "fmt": "pnpm lint && pnpm prettier --write .", "lint": "eslint --ext .ts --fix --ignore-path .gitignore .", "build": "tsup && cp package.json ./dist/ && pnpm size-limit" }, "repository": { "type": "git", "url": "git+https://github.com/upstash/upstash-redis.git" }, "keywords": [ "redis", "database", "serverless", "edge", "upstash" ], "author": "Andreas Thomas <andreas.thomas@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/upstash-redis/issues" }, "homepage": "https://github.com/upstash/upstash-redis#readme", "directories": { "examples": "examples" }, "devDependencies": { "@jest/globals": "^27.4.6", "@size-limit/preset-small-lib": "^7.0.8", "@trivago/prettier-plugin-sort-imports": "^3.2.0", "@types/jest": "^27.4.0", "@types/node": "^17.0.8", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "dotenv": "^12.0.3", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "jest": "^27.4.7", "prettier": "^2.5.1", "size-limit": "^7.0.8", "ts-jest": "^27.1.3", "tsup": "^5.11.11", "typescript": "^4.5.5" }, "dependencies": { "isomorphic-fetch": "^3.0.0" }, "browser": { "isomorphic-fetch": false }, "size-limit": [ { "path": "dist/index.js", "limit": "5 KB" }, { "path": "dist/index.mjs", "limit": "5 KB" }, { "path": "dist/cloudflare.js", "limit": "5 KB" }, { "path": "dist/cloudflare.mjs", "limit": "5 KB" }, { "path": "dist/nodejs.js", "limit": "5 KB" }, { "path": "dist/nodejs.mjs", "limit": "5 KB" }, { "path": "dist/fastly.js", "limit": "5 KB" }, { "path": "dist/fastly.mjs", "limit": "5 KB" } ] }