AIDK API Reference / aidk-express / withEngine
Function: withEngine() ​
ts
function withEngine<TBody>(config: ExpressEngineConfig<TBody>): (req: Request, res: Response, next: NextFunction) => void;Defined in: packages/express/src/middleware/engine.ts:116
Creates middleware that extracts execution context from the request.
Type Parameters ​
| Type Parameter | Default type |
|---|---|
TBody | any |
Parameters ​
| Parameter | Type | Description |
|---|---|---|
config | ExpressEngineConfig<TBody> | Configuration for context extraction |
Returns ​
Express middleware
ts
(
req: Request,
res: Response,
next: NextFunction): void;Parameters ​
| Parameter | Type |
|---|---|
req | Request |
res | Response |
next | NextFunction |
Returns ​
void
Example ​
typescript
app.use(withEngine({ engine: getEngine() }));
// In handler:
router.post('/execute', (req: EngineRequest, res) => {
const { engine, input, executionId } = req.engineContext;
const result = await engine.execute.withContext(req.engineContext.withContext)(
input,
<MyWorkflow />
);
});