Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

upstash

БесплатноБез исполняемых скриптовНе проверен

Upstash is a serverless data platform with HTTP-based Redis, rate limiting, QStash message delivery and Workflow for durable functions. Use when adding…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Upstash: Serverless Redis, QStash and Workflow

Overview

Upstash sells serverless building blocks that talk HTTP, so they work from Vercel, Cloudflare Workers, Netlify, Deno and Lambda without connection pools:

  • Redis via @upstash/redis (REST client; any Redis client also works over TCP) and @upstash/ratelimit.
  • QStash: delivers an HTTP request to your endpoint with retries, delays, cron schedules and fan-out (@upstash/qstash).
  • Workflow: durable multi-step functions on top of QStash (@upstash/workflow).
  • Also in the current catalog: Vector, Search, Box (sandboxes) and Blob. Upstash Kafka no longer appears in the current docs or product list, so do not build on it.

Pricing changes; read https://upstash.com/pricing/redis and the QStash pricing page rather than trusting numbers in code comments. At the time of checking the Redis free tier was one database with 250 MB of data and 500K commands per month.

Instructions

Step 1: Install and configure

npm install @upstash/redis @upstash/ratelimit @upstash/qstash @upstash/workflow

Create a database in the Upstash Console (console.upstash.com) and copy the REST credentials into the environment. Never commit them, and never expose them to browser code.

UPSTASH_REDIS_REST_URL="https://eu1-calm-lynx-12345.upstash.io"
UPSTASH_REDIS_REST_TOKEN="AbCdEf..."
QSTASH_TOKEN="eyJVc2VySUQi..."
QSTASH_CURRENT_SIGNING_KEY="sig_..."
QSTASH_NEXT_SIGNING_KEY="sig_..."

Step 2: Caching and sessions with Redis

import { Redis } from "@upstash/redis";

const redis = Redis.fromEnv();   // UPSTASH_REDIS_REST_URL + UPSTASH_REDIS_REST_TOKEN

async function getCachedUser(userId: string): Promise<User> {
  const cached = await redis.get<User>(`user:${userId}`);   // JSON is (de)serialized for you
  if (cached) return cached;

  const user = await db.users.findById(userId);
  await redis.set(`user:${userId}`, user, { ex: 3600 });     // 1 hour TTL
  return user;
}

// Session as a hash with a 24 h TTL
await redis.hset(`session:${sessionId}`, { userId: "42", role: "admin" });
await redis.expire(`session:${sessionId}`, 86400);
const session = await redis.hgetall<{ userId: string; role: string }>(`session:${sessionId}`);

// One HTTP round-trip for several commands
const pipe = redis.pipeline();
pipe.incr("stats:page-views");
pipe.sadd("stats:visitors", "usr_42");
const [views] = await pipe.exec<[number, number]>();

The client auto-deserializes JSON, so a stored string like "123" may come back as a number. Store plain strings only if you handle that.

Step 3: Rate limiting

import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";

const ratelimit = new Ratelimit({
  redis: Redis.fromEnv(),
  limiter: Ratelimit.slidingWindow(10, "10 s"),   // also fixedWindow, tokenBucket
  analytics: true,
  prefix: "ratelimit:api",
});

export async function POST(req: Request) {
  const ip = req.headers.get("x-forwarded-for") ?? "anonymous";
  const { success, limit, remaining, reset, pending } = await ratelimit.limit(ip);
  await pending;   // analytics and multi-region sync finish here; on edge use waitUntil(pending)

  if (!success) {
    return new Response("Too Many Requests", {
      status: 429,
      headers: {
        "X-RateLimit-Limit": String(limit),
        "X-RateLimit-Remaining": String(remaining),
        "X-RateLimit-Reset": String(reset),
      },
    });
  }
  return Response.json({ ok: true });
}

Step 4: QStash messages and schedules

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

const qstash = new Client({ token: process.env.QSTASH_TOKEN! });

// One-off delivery with retries and a delay
await qstash.publishJSON({
  url: "https://shop.vercel.app/api/process-order",   // must be publicly reachable
  body: { orderId: "ord-123", action: "fulfill" },
  retries: 3,
  delay: "30s",
  callback: "https://shop.vercel.app/api/order-done",
  failureCallback: "https://shop.vercel.app/api/order-failed",
});

// Recurring (cron, UTC unless a timezone is set)
await qstash.schedules.create({
  destination: "https://shop.vercel.app/api/daily-report",
  cron: "0 9 * * *",
});

Anyone can POST to your endpoint, so verify the QStash signature before acting:

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

const receiver = new Receiver({
  currentSigningKey: process.env.QSTASH_CURRENT_SIGNING_KEY!,
  nextSigningKey: process.env.QSTASH_NEXT_SIGNING_KEY!,
});

export async function POST(req: Request) {
  const body = await req.text();   // verify the raw body, before JSON.parse
  const valid = await receiver.verify({
    signature: req.headers.get("upstash-signature") ?? "",
    body,
  });
  if (!valid) return new Response("Invalid signature", { status: 401 });

  const { orderId } = JSON.parse(body);
  await fulfillOrder(orderId);
  return new Response("ok");
}

For Next.js there are wrappers, verifySignatureAppRouter from `@upstash/

Полный SKILL.md на GitHub

Установить upstash в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл upstash?

Upstash is a serverless data platform with HTTP-based Redis, rate limiting, QStash message delivery and Workflow for durable functions. Use when adding caching, sessions, rate limiting, delayed jobs, cron schedules or multi-step background workflows to Vercel, Next.js, Cloudflare Workers or AWS Lambda apps that cannot hold persistent connections.

Как установить скилл upstash?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл upstash запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить upstash с