UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

53 lines (52 loc) 1.8 kB
/** * Abort Signal Middleware * Provides client disconnection handling for long-running requests */ import type { AbortSignalMiddlewareOptions, MiddlewareDefinition } from "../../types/index.js"; /** * Create abort signal middleware for handling client disconnections. * * This middleware creates an AbortController and attaches its signal to the context, * allowing route handlers to check for client disconnection during long-running operations. * * @param options - Optional configuration * @returns Middleware that attaches abort signal to context * * @example * ```typescript * const abortMiddleware = createAbortSignalMiddleware(); * server.registerMiddleware(abortMiddleware); * * // In route handler: * const signal = ctx.abortSignal; * await longRunningOperation({ signal }); * ``` */ export declare function createAbortSignalMiddleware(options?: AbortSignalMiddlewareOptions): MiddlewareDefinition; /** * Express-specific middleware factory. * Use this directly with Express adapter for optimal handling. * * This is a lower-level middleware that works directly with Express * request/response objects rather than the unified ServerContext. * * @param options - Optional configuration * @returns Express middleware function * * @example * ```typescript * // In Express adapter * app.use(createExpressAbortMiddleware()); * * // Access in route handler * app.get('/api/stream', (req, res) => { * const signal = res.locals.abortSignal; * // Use signal for cancellation * }); * ``` */ export declare function createExpressAbortMiddleware(options?: AbortSignalMiddlewareOptions): (req: unknown, res: { on: (event: string, cb: () => void) => void; writableFinished?: boolean; locals: Record<string, unknown>; }, next: () => void) => void;