• Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 2 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Message queue for serverless

Upstash QStash SDK

npm (scoped)

QStash is an HTTP based messaging and scheduling solution for serverless and edge runtimes.

It is 100% built on stateless HTTP requests and designed for:

  • Serverless functions (AWS Lambda ...)
  • Cloudflare Workers (see the example)
  • Fastly Compute@Edge
  • Next.js, including edge
  • Deno
  • Client side web/mobile applications
  • WebAssembly
  • and other environments where HTTP is preferred over TCP.

How does QStash work?

QStash is the message broker between your serverless apps. You send an HTTP request to QStash, that includes a destination, a payload and optional settings. We durably store your message and will deliver it to the destination API via HTTP. In case the destination is not ready to receive the message, we will retry the message later, to guarentee at-least-once delivery.

Quick Start

Install

npm

npm install @upstash/qstash

Get your authorization token

Go to upstash and copy the token.

Basic Usage:

Publishing a message

import { Client } from "@upstash/qstash";
/**
 * Import a fetch polyfill only if you are using node prior to v18.
 * This is not necessary for nextjs, deno or cloudflare workers.
 */
import "isomorphic-fetch";

const c = new Client({
  token: "<QSTASH_TOKEN>",
});

const res = await c.publishJSON({
  url: "https://my-api...",
  // or topic: "the name or id of a topic"
  body: {
    hello: "world",
  },
});
console.log(res);
// { messageId: "msg_xxxxxxxxxxxxxxxx" }

Receiving a message

How to receive a message depends on your http server. The Receiver.verify method should be called by you as the first step in your handler function.

import { Receiver } from "@upstash/qstash";

const r = new Receiver({
  currentSigningKey: "..",
  nextSigningKey: "..",
});

const isValid = await r.verify({
  /**
   * The signature from the `Upstash-Signature` header.
   *
   * Please note that on some platforms (e.g. Vercel or Netlify) you might
   * receive the header in lower case: `upstash-signature` 
   *
   */
  signature: "string";

  /**
   * The raw request body.
   */
  body: "string";

  /**
   * Number of seconds to tolerate when checking `nbf` and `exp` claims, to deal with small clock differences among different servers
   *
   * @default 0
   */
  clockTolerance?: number;
})

Docs

See the documentation for details.

Contributing

Install Deno

More Repositories

1

ratelimit-js

Rate limiting library for serverless runtimes
TypeScript
1,633
star
2

redis-js

HTTP based Redis Client for Serverless and Edge Functions
TypeScript
655
star
3

upsy

Your new mate on Discord and Slack. Powered by AI.
TypeScript
190
star
4

semantic-cache

A fuzzy key value store based on semantic similarity rather lexical equality.
TypeScript
184
star
5

roadmap

Build and deploy a roadmap voting app for your project/product.
TypeScript
169
star
6

rag-chat

Batteries included SDK for RAG development.
TypeScript
148
star
7

degree-guru

AI chatbot for expert answers on university degrees
TypeScript
128
star
8

redis-examples

Sample applications implemented with serverless Redis
JavaScript
126
star
9

claps

Adds clap button (like medium) to any page for your Next.js apps.
TypeScript
104
star
10

kafka-js

HTTP based Kafka Client for Serverless and Edge Functions
TypeScript
100
star
11

feedback

Feedback Component for Next.js
TypeScript
90
star
12

queue

SQS like stream based queue on top of Redis
TypeScript
81
star
13

edge-flags

Feature flags for edge functions
TypeScript
69
star
14

faq-generator

Generate FAQ for your documentation. Powered by OpenAI, Vercel and Upstash.
TypeScript
59
star
15

chatbox

TypeScript
58
star
16

vector-js

Upstash Vector JS SDK
TypeScript
39
star
17

hackerdigest

Stay in the loop without the time sink. ๐Ÿš€
TypeScript
36
star
18

examples

Examples how to use Upstash with various tech
TypeScript
29
star
19

query

Secondary indexing and query capabilities for Upstash Redis
TypeScript
29
star
20

waiting-room

A Waiting Room for your website with Cloudflare Workers and Serverless Redis
JavaScript
28
star
21

latency-comparison

Latency Comparison among Serverless Databases: DynamoDB, FaunaDB, MongoDB, Cassandra, Firestore and Upstash
JavaScript
26
star
22

redis-py

HTTP based Python Redis Client for Serverless and Edge Functions
Python
24
star
23

terraform-provider-upstash

Go
22
star
24

cli

Upstash CLI for serverless Redis and Kafka
TypeScript
20
star
25

ratelimit-py

Rate limiting library for serverless runtimes in Python
Python
20
star
26

react-ui

Various react components from our console
TypeScript
19
star
27

lock

TypeScript
18
star
28

core-analytics

Low level analytics building blocks for redis
TypeScript
15
star
29

vercel-note-taker-slackbot

Serverless Slackbot with Vercel
JavaScript
15
star
30

qstash-examples

TypeScript
11
star
31

qstash-py

Python SDK for Upstash QStash
Python
11
star
32

pulumi-upstash

Python
10
star
33

docs

Upstash documentation
MDX
9
star
34

vector-py

Upstash Vector Python SDK
Python
9
star
35

semantic-cache-py

A fuzzy key value store based on semantic similarity rather lexical equality. (python version)
Python
8
star
36

upstash-web

MDX
8
star
37

kafka-examples

Sample applications implemented with Serverless Kafka
JavaScript
8
star
38

stylegenie

JavaScript
7
star
39

serverless-birthday-slackbot

Python
6
star
40

vector-go

Upstash Vector Golang SDK
Go
6
star
41

qstash-go

Go SDK for Upstash QStash
Go
5
star
42

jstack

Confidently ship high-performance, low-cost Next.js apps
TypeScript
4
star
43

rdb

RDB file parser
Go
4
star
44

upstash-cloudformation

Cloudformation private types to provision Upstash infrastructure
TypeScript
3
star
45

upstash-heroku-todo-app

JavaScript
3
star
46

upstats

TypeScript
3
star
47

edge-caching-benchmark

JavaScript
2
star
48

sponsorship

1
star
49

purple-squirrel

TypeScript
1
star
50

transcriber

TypeScript
1
star
51

next-template

TypeScript
1
star
52

redis-connection-benchmark

benchmark the overhead of a Redis connection
JavaScript
1
star
53

QuickApply

A chatbot which will welcome job candidates, do prescreening and answer questions.
JavaScript
1
star
54

kafka-connectors

Kafka Connect with Upstash Kafkaยฎ
Shell
1
star
55

issues

Issue Tracker for Upstash
1
star