Skip to content

AIDK API Reference / aidk-express / withTransport

Function: withTransport() ​

ts
function withTransport(config: TransportConfig): (req: Request, res: Response, next: NextFunction) => Promise<void>;

Defined in: packages/express/src/middleware/engine.ts:198

Creates middleware that joins the SSE connection to appropriate rooms. Must be used after withEngine middleware.

Parameters ​

ParameterTypeDescription
configTransportConfigTransport configuration

Returns ​

Express middleware

ts
(
   req: Request, 
   res: Response, 
   next: NextFunction): Promise<void>;

Parameters ​

ParameterType
reqRequest
resResponse
nextNextFunction

Returns ​

Promise<void>

Example ​

typescript
app.use(withEngine({ engine }));
app.use(withTransport({ transport: getSSETransport() }));

// Custom room pattern:
app.use(withTransport({
  transport,
  roomPattern: (ctx) => `org:${ctx.tenantId}:thread:${ctx.threadId}`,
}));

Released under the MIT License.