@upstash/qstash 2.7.11 → 2.7.12

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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +167 -0
  3. package/package.json +1 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Upstash, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,167 @@
1
+ # Upstash QStash SDK
2
+
3
+ ![npm (scoped)](https://img.shields.io/npm/v/@upstash/qstash)
4
+
5
+ > [!NOTE]
6
+ > **This project is in GA Stage.**
7
+ > The Upstash Professional Support fully covers this project. It receives regular updates, and bug fixes.
8
+ > The Upstash team is committed to maintaining and improving its functionality.
9
+
10
+ **QStash** is an HTTP based messaging and scheduling solution for serverless and
11
+ edge runtimes.
12
+
13
+ It is 100% built on stateless HTTP requests and designed for:
14
+
15
+ - Serverless functions (AWS Lambda ...)
16
+ - Cloudflare Workers (see
17
+ [the example](https://github.com/upstash/sdk-qstash-ts/tree/main/examples/cloudflare-workers))
18
+ - Fastly Compute@Edge
19
+ - Next.js, including [edge](https://nextjs.org/docs/api-reference/edge-runtime)
20
+ - Deno
21
+ - Client side web/mobile applications
22
+ - WebAssembly
23
+ - and other environments where HTTP is preferred over TCP.
24
+
25
+ ## How does QStash work?
26
+
27
+ QStash is the message broker between your serverless apps. You send an HTTP
28
+ request to QStash, that includes a destination, a payload and optional settings.
29
+ We durably store your message and will deliver it to the destination API via
30
+ HTTP. In case the destination is not ready to receive the message, we will retry
31
+ the message later, to guarentee at-least-once delivery.
32
+
33
+ ## Quick Start
34
+
35
+ ### Install
36
+
37
+ #### npm
38
+
39
+ ```bash
40
+ npm install @upstash/qstash
41
+ ```
42
+
43
+ ### Get your authorization token
44
+
45
+ Go to [Upstash Console](https://console.upstash.com/qstash) and copy the QSTASH_TOKEN.
46
+
47
+ ## Basic Usage:
48
+
49
+ ### Publishing a message
50
+
51
+ ```ts
52
+ import { Client } from "@upstash/qstash";
53
+ /**
54
+ * Import a fetch polyfill only if you are using node prior to v18.
55
+ * This is not necessary for nextjs, deno or cloudflare workers.
56
+ */
57
+ import "isomorphic-fetch";
58
+
59
+ const client = new Client({
60
+ token: "<QSTASH_TOKEN>",
61
+ });
62
+
63
+ const res = await client.publishJSON({
64
+ url: "https://my-api...",
65
+ // or urlGroup: "the name or id of a url group"
66
+ body: {
67
+ hello: "world",
68
+ },
69
+ });
70
+ console.log(res);
71
+ // { messageId: "msg_xxxxxxxxxxxxxxxx" }
72
+ ```
73
+
74
+ ### Receiving a message
75
+
76
+ How to receive a message depends on your http server. The `Receiver.verify`
77
+ method should be called by you as the first step in your handler function.
78
+
79
+ ```ts
80
+ import { Receiver } from "@upstash/qstash";
81
+
82
+ const r = new Receiver({
83
+ currentSigningKey: "..",
84
+ nextSigningKey: "..",
85
+ });
86
+
87
+ const isValid = await r.verify({
88
+ /**
89
+ * The signature from the `Upstash-Signature` header.
90
+ *
91
+ * Please note that on some platforms (e.g. Vercel or Netlify) you might
92
+ * receive the header in lower case: `upstash-signature`
93
+ *
94
+ */
95
+ signature: "string";
96
+
97
+ /**
98
+ * The raw request body.
99
+ */
100
+ body: "string";
101
+ })
102
+ ```
103
+
104
+ ### Publishing a message to an LLM provider
105
+
106
+ No need for complicated setup your LLM request. We'll call LLM and schedule it for your serverless needs.
107
+
108
+ ```ts
109
+ import { Client, openai } from "@upstash/qstash";
110
+
111
+ const client = new Client({
112
+ token: "<QSTASH_TOKEN>",
113
+ });
114
+
115
+ const result = await client.publishJSON({
116
+ api: { name: "llm", provider: openai({ token: process.env.OPENAI_API_KEY! }) },
117
+ body: {
118
+ model: "gpt-3.5-turbo",
119
+ messages: [
120
+ {
121
+ role: "user",
122
+ content: "Where is the capital of Turkey?",
123
+ },
124
+ ],
125
+ },
126
+ callback: "https://oz.requestcatcher.com/",
127
+ });
128
+ ```
129
+
130
+ ## Docs
131
+
132
+ See [the documentation](https://docs.upstash.com/qstash) for details.
133
+
134
+ ## Contributing
135
+
136
+ ### Setup
137
+
138
+ This project requires [Bun](https://bun.sh/) to be installed. Please see the [Bun installation documentation](https://bun.sh/docs/installation) for further instructions.
139
+
140
+ Once you have cloned the project, you will need to install the dependencies and then you can run the project.
141
+
142
+ ```sh
143
+ bun install
144
+ bun run build
145
+ ```
146
+
147
+ ### Testing
148
+
149
+ To begin testing, environment variables will need to be setup. First, create a `.env` file in the root of the project. [`.env.template`](/.env.template) can be used as a template. Your values can be found in the [Qstash Console](https://console.upstash.com/qstash).
150
+
151
+ ```sh
152
+ bun run test
153
+ ```
154
+
155
+ ### Committing
156
+
157
+ This project uses [commitlint](https://commitlint.js.org/). When committing, please ensure your commit message is formatted to include an appropriate prefix with the message.
158
+
159
+ #### Examples
160
+
161
+ ```
162
+ fix: typescript bug
163
+ feat: use new logger
164
+ perf: refactor cache
165
+ ```
166
+
167
+ For a full list of options, please see the [`commitlint.config.js`](/commitlint.config.js) file.
package/package.json CHANGED
@@ -1 +1 @@
1
- {"version":"v2.7.11","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/sdk-qstash-ts#readme","repository":{"type":"git","url":"git+https://github.com/upstash/sdk-qstash-ts.git"},"bugs":{"url":"https://github.com/upstash/sdk-qstash-ts/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./nuxt":{"import":"./nuxt.mjs","require":"./nuxt.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"}},"keywords":["qstash","queue","events","serverless","upstash"],"scripts":{"build":"tsup && cp ./package.json ./dist","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@eslint/eslintrc":"^3.1.0","@eslint/js":"^9.10.0","@solidjs/start":"^1.0.6","@sveltejs/kit":"^2.5.18","@types/bun":"^1.1.1","@types/crypto-js":"^4.2.0","@typescript-eslint/eslint-plugin":"^8.4.0","@typescript-eslint/parser":"^8.4.0","ai":"^3.1.28","bun-types":"^1.1.7","eslint":"^9.10.0","eslint-plugin-unicorn":"^51.0.1","h3":"^1.12.0","hono":"^4.5.8","husky":"^9.0.10","next":"^14.0.2","prettier":"^3.2.5","tsup":"latest","typescript":"^5.4.5","undici-types":"^6.16.0","vitest":"latest"},"dependencies":{"crypto-js":">=4.2.0","jose":"^5.2.3","neverthrow":"^7.0.1"}}
1
+ {"version":"v2.7.12","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/sdk-qstash-ts#readme","repository":{"type":"git","url":"git+https://github.com/upstash/sdk-qstash-ts.git"},"bugs":{"url":"https://github.com/upstash/sdk-qstash-ts/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./nuxt":{"import":"./nuxt.mjs","require":"./nuxt.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"}},"keywords":["qstash","queue","events","serverless","upstash"],"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@eslint/eslintrc":"^3.1.0","@eslint/js":"^9.10.0","@solidjs/start":"^1.0.6","@sveltejs/kit":"^2.5.18","@types/bun":"^1.1.1","@types/crypto-js":"^4.2.0","@typescript-eslint/eslint-plugin":"^8.4.0","@typescript-eslint/parser":"^8.4.0","ai":"^3.1.28","bun-types":"^1.1.7","eslint":"^9.10.0","eslint-plugin-unicorn":"^51.0.1","h3":"^1.12.0","hono":"^4.5.8","husky":"^9.0.10","next":"^14.0.2","prettier":"^3.2.5","tsup":"latest","typescript":"^5.4.5","undici-types":"^6.16.0","vitest":"latest"},"dependencies":{"crypto-js":">=4.2.0","jose":"^5.2.3","neverthrow":"^7.0.1"}}