@upstash/redis 0.0.0-ci.e475de1f85007c6e91b7c723aae0092693599d18-20231218001438 → 0.0.0-ci.e4eab2833c7196d06833dccf8f132ddbc18c2cfa-20241008071408

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
@@ -1 +1,110 @@
1
- import{a as o,b as r,c as i}from"./chunk-3KV34DA6.mjs";typeof atob>"u"&&(global.atob=function(n){return Buffer.from(n,"base64").toString("utf-8")});var a=class n extends r{constructor(e){if("request"in e){super(e);return}(e.url.startsWith(" ")||e.url.endsWith(" ")||/\r|\n/.test(e.url))&&console.warn("The redis url contains whitespace or newline, which can cause errors!"),(e.token.startsWith(" ")||e.token.endsWith(" ")||/\r|\n/.test(e.token))&&console.warn("The redis token contains whitespace or newline, which can cause errors!");let t=new o({baseUrl:e.url,retry:e.retry,headers:{authorization:`Bearer ${e.token}`},agent:e.agent,responseEncoding:e.responseEncoding,cache:e.cache||"no-store",signal:e.signal});super(t,{automaticDeserialization:e.automaticDeserialization,enableTelemetry:!process.env.UPSTASH_DISABLE_TELEMETRY}),this.addTelemetry({runtime:typeof EdgeRuntime=="string"?"edge-light":`node@${process.version}`,platform:process.env.VERCEL?"vercel":process.env.AWS_REGION?"aws":"unknown",sdk:`@upstash/redis@${i}`})}static fromEnv(e){if(typeof process?.env>"u")throw new Error('Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead');let t=process?.env.UPSTASH_REDIS_REST_URL;if(!t)throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");let s=process?.env.UPSTASH_REDIS_REST_TOKEN;if(!s)throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");return new n({...e,url:t,token:s})}};export{a as Redis};
1
+ import {
2
+ HttpClient,
3
+ Redis,
4
+ VERSION,
5
+ error_exports
6
+ } from "./chunk-6OUEAHUL.mjs";
7
+
8
+ // platforms/nodejs.ts
9
+ if (typeof atob === "undefined") {
10
+ global.atob = (b64) => Buffer.from(b64, "base64").toString("utf8");
11
+ }
12
+ var Redis2 = class _Redis extends Redis {
13
+ /**
14
+ * Create a new redis client by providing a custom `Requester` implementation
15
+ *
16
+ * @example
17
+ * ```ts
18
+ *
19
+ * import { UpstashRequest, Requester, UpstashResponse, Redis } from "@upstash/redis"
20
+ *
21
+ * const requester: Requester = {
22
+ * request: <TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>> => {
23
+ * // ...
24
+ * }
25
+ * }
26
+ *
27
+ * const redis = new Redis(requester)
28
+ * ```
29
+ */
30
+ constructor(configOrRequester) {
31
+ if ("request" in configOrRequester) {
32
+ super(configOrRequester);
33
+ return;
34
+ }
35
+ if (!configOrRequester.url) {
36
+ throw new Error(
37
+ `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
38
+ );
39
+ }
40
+ if (!configOrRequester.token) {
41
+ throw new Error(
42
+ `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
43
+ );
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!");
50
+ }
51
+ const client = new HttpClient({
52
+ baseUrl: configOrRequester.url,
53
+ retry: configOrRequester.retry,
54
+ headers: { authorization: `Bearer ${configOrRequester.token}` },
55
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
56
+ agent: configOrRequester.agent,
57
+ responseEncoding: configOrRequester.responseEncoding,
58
+ cache: configOrRequester.cache ?? "no-store",
59
+ signal: configOrRequester.signal,
60
+ keepAlive: configOrRequester.keepAlive,
61
+ readYourWrites: configOrRequester.readYourWrites
62
+ });
63
+ super(client, {
64
+ automaticDeserialization: configOrRequester.automaticDeserialization,
65
+ enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
66
+ latencyLogging: configOrRequester.latencyLogging,
67
+ enableAutoPipelining: configOrRequester.enableAutoPipelining
68
+ });
69
+ this.addTelemetry({
70
+ runtime: (
71
+ // @ts-expect-error to silence compiler
72
+ typeof EdgeRuntime === "string" ? "edge-light" : `node@${process.version}`
73
+ ),
74
+ platform: process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
75
+ sdk: `@upstash/redis@${VERSION}`
76
+ });
77
+ if (this.enableAutoPipelining) {
78
+ return this.autoPipeline();
79
+ }
80
+ }
81
+ /**
82
+ * Create a new Upstash Redis instance from environment variables.
83
+ *
84
+ * Use this to automatically load connection secrets from your environment
85
+ * variables. For instance when using the Vercel integration.
86
+ *
87
+ * This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from
88
+ * your environment using `process.env`.
89
+ */
90
+ static fromEnv(config) {
91
+ if (process.env === void 0) {
92
+ 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
+ );
95
+ }
96
+ const url = process.env.UPSTASH_REDIS_REST_URL;
97
+ if (!url) {
98
+ throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
99
+ }
100
+ const token = process.env.UPSTASH_REDIS_REST_TOKEN;
101
+ if (!token) {
102
+ throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`");
103
+ }
104
+ return new _Redis({ ...config, url, token });
105
+ }
106
+ };
107
+ export {
108
+ Redis2 as Redis,
109
+ error_exports as errors
110
+ };
package/package.json CHANGED
@@ -1 +1 @@
1
- { "name": "@upstash/redis", "version": "v0.0.0-ci.e475de1f85007c6e91b7c723aae0092693599d18-20231218001438", "main": "./nodejs.js", "module": "./nodejs.mjs", "types": "./nodejs.d.ts", "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 README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/", "test": "bun test pkg --coverage", "fmt": "bunx @biomejs/biome check --apply ./pkg" }, "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", "typesVersions": { "*": { "nodejs": [ "./nodejs.d.ts" ], "cloudflare": [ "./cloudflare.d.ts" ], "fastly": [ "./fastly.d.ts" ] } }, "devDependencies": { "@types/crypto-js": "^4.1.3", "bun-types": "^1.0.6", "tsup": "^7.2.0", "@biomejs/biome": "^1.3.0" }, "dependencies": { "crypto-js": "^4.2.0" } }
1
+ {"name":"@upstash/redis","version":"v0.0.0-ci.e4eab2833c7196d06833dccf8f132ddbc18c2cfa-20241008071408","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","@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"}}