upstash-workflow-js

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Upstash Workflow SDK

Upstash Workflow SDK

Quick Start

快速开始

The Upstash Workflow SDK lets you expose serverless workflow endpoints and run them reliably using QStash under the hood.
Install:
bash
npm install @upstash/workflow
Define a simple workflow endpoint:
ts
import { serve } from "@upstash/workflow";

export const { POST } = serve(async (context) => {
  await context.run("step-1", () => console.log("step 1"));
  await context.run("step-2", () => console.log("step 2"));
});
Trigger it from your backend:
ts
import { Client } from "@upstash/workflow";

const client = new Client({ token: process.env.QSTASH_TOKEN! });
await client.trigger({ url: "https://your-app.com/api/workflow" });
Upstash Workflow SDK允许你暴露无服务器工作流端点,并在底层使用QStash可靠地运行它们。
安装:
bash
npm install @upstash/workflow
定义一个简单的工作流端点:
ts
import { serve } from "@upstash/workflow";

export const { POST } = serve(async (context) => {
  await context.run("step-1", () => console.log("step 1"));
  await context.run("step-2", () => console.log("step 2"));
});
从你的后端触发它:
ts
import { Client } from "@upstash/workflow";

const client = new Client({ token: process.env.QSTASH_TOKEN! });
await client.trigger({ url: "https://your-app.com/api/workflow" });

Other Skill Files

其他技能文件

These files contain the full documentation. Use them for details, patterns, and advanced behavior.
  • basics:
    • basics/serve – How to expose workflow endpoints.
    • basics/context – Full API for workflow
      context
      (steps, waits, webhooks, events, invoke, etc.).
    • basics/client – Using the Workflow client to trigger, cancel, inspect, and notify runs.
  • features:
    • features/invoke – Cross‑workflow invocation.
    • features/reliability – Retries, failure callbacks, and DLQ.
    • features/flow-control – Rate limits, concurrency, and parallelism.
    • features/wait-for-event – Notify and wait-for-event patterns.
    • features/webhooks – Webhook creation and consumption.
  • how to:
    • how-to/local-dev – Local QStash dev server and tunneling.
    • how-to/realtime – Realtime and human‑in‑the‑loop workflows.
    • how-to/migrations – Migrating workflows safely.
    • how-to/middleware – Adding middleware to workflows.
  • other files:
    • rest-api – Low-level REST endpoints for interacting with QStash/Workflow.
    • troubleshooting – Common debugging and environment issues.
    • agents – Using Workflow with agents, orchestrators, and automation patterns.
这些文件包含完整文档。如需了解详细信息、模式和高级行为,请参考它们。
  • 基础部分:
    • basics/serve – 如何暴露工作流端点。
    • basics/context – 工作流
      context
      的完整API(步骤、等待、Webhook、事件、调用等)。
    • basics/client – 使用Workflow客户端触发、取消、检查和通知工作流运行。
  • 功能部分:
    • features/invoke – 跨工作流调用。
    • features/reliability – 重试、失败回调和死信队列(DLQ)。
    • features/flow-control – 速率限制、并发和并行处理。
    • features/wait-for-event – 通知和等待事件模式。
    • features/webhooks – Webhook的创建与使用。
  • 操作指南:
    • how-to/local-dev – 本地QStash开发服务器和隧道。
    • how-to/realtime – 实时和人机交互工作流。
    • how-to/migrations – 安全迁移工作流。
    • how-to/middleware – 为工作流添加中间件。
  • 其他文件:
    • rest-api – 用于与QStash/Workflow交互的底层REST端点。
    • troubleshooting – 常见调试和环境问题。
    • agents – 将Workflow与Agent、编排器和自动化模式结合使用。