@upstash/redis 0.0.0-ci.fd62df5f23c9d3ce31f52781474d711bbed876d2-20231031095501 → 0.0.0-ci.ff7a0b135b28ff50a7e2634a78123684be3ed71f-20241105152627

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,113 @@
1
- import{a as o,b as r,c as i}from"./chunk-6556OV4Z.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"});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-O2BCOVQA.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
+ console.warn(
37
+ `[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
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
+ );
43
+ }
44
+ if (!configOrRequester.token) {
45
+ console.warn(
46
+ `[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
47
+ );
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
+ );
52
+ }
53
+ const client = new HttpClient({
54
+ baseUrl: configOrRequester.url,
55
+ retry: configOrRequester.retry,
56
+ headers: { authorization: `Bearer ${configOrRequester.token}` },
57
+ agent: configOrRequester.agent,
58
+ responseEncoding: configOrRequester.responseEncoding,
59
+ cache: configOrRequester.cache ?? "no-store",
60
+ signal: configOrRequester.signal,
61
+ keepAlive: configOrRequester.keepAlive,
62
+ readYourWrites: configOrRequester.readYourWrites
63
+ });
64
+ super(client, {
65
+ automaticDeserialization: configOrRequester.automaticDeserialization,
66
+ enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
67
+ latencyLogging: configOrRequester.latencyLogging,
68
+ enableAutoPipelining: configOrRequester.enableAutoPipelining
69
+ });
70
+ this.addTelemetry({
71
+ runtime: (
72
+ // @ts-expect-error to silence compiler
73
+ typeof EdgeRuntime === "string" ? "edge-light" : `node@${process.version}`
74
+ ),
75
+ platform: process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
76
+ sdk: `@upstash/redis@${VERSION}`
77
+ });
78
+ if (this.enableAutoPipelining) {
79
+ return this.autoPipeline();
80
+ }
81
+ }
82
+ /**
83
+ * Create a new Upstash Redis instance from environment variables.
84
+ *
85
+ * Use this to automatically load connection secrets from your environment
86
+ * variables. For instance when using the Vercel integration.
87
+ *
88
+ * This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from
89
+ * your environment using `process.env`.
90
+ */
91
+ static fromEnv(config) {
92
+ if (process.env === void 0) {
93
+ throw new TypeError(
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'
95
+ );
96
+ }
97
+ const url = process.env.UPSTASH_REDIS_REST_URL || process.env.KV_REST_API_URL;
98
+ if (!url) {
99
+ console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
100
+ }
101
+ const token = process.env.UPSTASH_REDIS_REST_TOKEN || process.env.KV_REST_API_TOKEN;
102
+ if (!token) {
103
+ console.warn(
104
+ "[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
105
+ );
106
+ }
107
+ return new _Redis({ ...config, url, token });
108
+ }
109
+ };
110
+ export {
111
+ Redis2 as Redis,
112
+ error_exports as errors
113
+ };
package/package.json CHANGED
@@ -1 +1 @@
1
- { "name": "@upstash/redis", "version": "v0.0.0-ci.fd62df5f23c9d3ce31f52781474d711bbed876d2-20231031095501", "main": "./nodejs.js", "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.ff7a0b135b28ff50a7e2634a78123684be3ed71f-20241105152627","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"}}