Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions docs/content/docs/getting-started/express.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Initialize the project:
npm init --y
```

### Install `workflow`, `express` and `nitro`
### Install `workflow`, `express`, `nitro`, and `rollup`

```package-install
npm i workflow express nitro rollup
Expand All @@ -50,13 +50,13 @@ npm i -D @types/express
Create a new file `nitro.config.ts` for your Nitro configuration with module `workflow/nitro`. This enables usage of the `"use workflow"` and `"use step"` directives.

```typescript title="nitro.config.ts" lineNumbers
import { defineNitroConfig } from 'nitro/config';
import { defineNitroConfig } from "nitro/config";

export default defineNitroConfig({
modules: ['workflow/nitro'],
vercel: { entryFormat: 'node' },
modules: ["workflow/nitro"],
vercel: { entryFormat: "node" },
routes: {
'/**': { handler: './src/index.ts', format: "node" },
'/**': { handler: './src/index.ts', format: 'node' },
},
});
```
Expand Down Expand Up @@ -193,7 +193,6 @@ To invoke your new workflow, we'll create both the Express app and a new API rou

```typescript title="src/index.ts"
import express from "express";
import { fromNodeHandler, type NodeMiddleware } from "nitro/h3";
import { start } from "workflow/api";
import { handleUserSignup } from "../workflows/user-signup.js";

Expand All @@ -206,7 +205,7 @@ app.post("/api/signup", async (req, res) => {
return res.json({ message: "User signup workflow started" });
});

export default fromNodeHandler(app as NodeMiddleware);
export default app;
```

This route handler creates a `POST` request endpoint at `/api/signup` that will trigger your workflow.
Expand Down
48 changes: 11 additions & 37 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion workbench/express/nitro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default defineNitroConfig({
modules: ['workflow/nitro'],
vercel: { entryFormat: 'node' },
routes: {
'/**': './src/index.ts',
'/**': { handler: './src/index.ts', format: 'node' },
},
plugins: ['plugins/start-pg-world.ts'],
});
5 changes: 2 additions & 3 deletions workbench/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
},
"dependencies": {
"express": "^5.1.0",
"nitro": "catalog:",
"srvx": "^0.9.2"
"nitro": "catalog:"
},
"devDependencies": {
"@workflow/world-postgres": "workspace:*",
"@types/express": "^5.0.5",
"@workflow/world-postgres": "workspace:*",
"ai": "catalog:",
"lodash.chunk": "^4.2.0",
"openai": "^6.1.0",
Expand Down
3 changes: 1 addition & 2 deletions workbench/express/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import express from 'express';
import { toFetchHandler } from 'srvx/node';
import { getHookByToken, getRun, resumeHook, start } from 'workflow/api';
import { hydrateWorkflowArguments } from 'workflow/internal/serialization';
import { allWorkflows } from '../_workflows.js';
Expand Down Expand Up @@ -208,4 +207,4 @@ app.post('/api/test-direct-step-call', async (req, res) => {
return res.json({ result });
});

export default toFetchHandler(app as any);
export default app;