Workflow SDK 的原生 Nitro v3 集成现已进入 Beta 阶段。步骤在与应用其余部分相同的捆绑运行时中运行,而不是使用单独的 bundle。Nitro 的 useStorage() 和其他服务端 API 可直接在 "use step" 函数内工作。
import { useStorage } from "nitro/storage";
export async function getUserPreferences(userId: string) {
"use step";
const storage = useStorage("cache");
return await storage.getItem(`preferences:${userId}`);
}
在步骤函数内读取 Nitro 存储
Nitro 开发服务器还会在 /_workflow 路径提供 workflow Web UI。在浏览器中打开即可检查、监控和调试 workflow 运行。
Workflow 路由现在由 Nitro 作为应用构建的一部分进行捆绑。依赖项会被追踪,未使用的代码会被摇树优化,因此输出仅包含实际运行的代码,构建速度更快且 bundle 更小。
开始使用 Workflow SDK on Nitro。
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.