Skip to content

Commit 2e25421

Browse files
authored
docs: fix express nitro config (#415)
* docs: fix express nitro config * docs: remove fromNodeHandler wrapper in express app * fix: dup import in docs * docs: fix use srvx toFetchHandler * docs: express add rollup deps * test * simplify express
1 parent 103900c commit 2e25421

File tree

5 files changed

+20
-28
lines changed

5 files changed

+20
-28
lines changed

docs/content/docs/getting-started/express.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Initialize the project:
2929
npm init --y
3030
```
3131

32-
### Install `workflow`, `express` and `nitro`
32+
### Install `workflow`, `express`, `nitro`, and `rollup`
3333

3434
```package-install
3535
npm i workflow express nitro rollup
@@ -50,13 +50,13 @@ npm i -D @types/express
5050
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.
5151

5252
```typescript title="nitro.config.ts" lineNumbers
53-
import { defineNitroConfig } from 'nitro/config';
53+
import { defineNitroConfig } from "nitro/config";
5454

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

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

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

209-
export default fromNodeHandler(app as NodeMiddleware);
208+
export default app;
210209
```
211210

212211
This route handler creates a `POST` request endpoint at `/api/signup` that will trigger your workflow.

pnpm-lock.yaml

Lines changed: 10 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workbench/express/nitro.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default defineNitroConfig({
44
modules: ['workflow/nitro'],
55
vercel: { entryFormat: 'node' },
66
routes: {
7-
'/**': './src/index.ts',
7+
'/**': { handler: './src/index.ts', format: 'node' },
88
},
99
plugins: ['plugins/start-pg-world.ts'],
1010
});

workbench/express/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
},
1616
"dependencies": {
1717
"express": "^5.1.0",
18-
"nitro": "catalog:",
19-
"srvx": "^0.9.2"
18+
"nitro": "catalog:"
2019
},
2120
"devDependencies": {
22-
"@workflow/world-postgres": "workspace:*",
2321
"@types/express": "^5.0.5",
22+
"@workflow/world-postgres": "workspace:*",
2423
"ai": "catalog:",
2524
"lodash.chunk": "^4.2.0",
2625
"openai": "^6.1.0",

workbench/express/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import express from 'express';
2-
import { toFetchHandler } from 'srvx/node';
32
import { getHookByToken, getRun, resumeHook, start } from 'workflow/api';
43
import { hydrateWorkflowArguments } from 'workflow/internal/serialization';
54
import { allWorkflows } from '../_workflows.js';
@@ -221,4 +220,4 @@ app.post('/api/test-direct-step-call', async (req, res) => {
221220
return res.json({ result });
222221
});
223222

224-
export default toFetchHandler(app as any);
223+
export default app;

0 commit comments

Comments
 (0)