nestjs-aborter
Version:
Automatic request cancellation and timeout handling for NestJS applications
21 lines (20 loc) • 723 B
TypeScript
/**
* Custom error thrown when an operation is aborted.
*/
export declare class AbortError extends Error {
constructor(reason?: string);
}
export interface WithAbortOptions {
timeout?: number;
timeoutMessage?: string;
}
/**
* Wraps a promise with abort signal and optional timeout support.
*
* @param promise - The promise to wrap
* @param signal - Optional AbortSignal to cancel the operation
* @param options - Optional timeout configuration
* @returns Promise that rejects with AbortError if aborted or timed out
* @throws Error if operation timeout exceeds request timeout
*/
export declare function withAbort<T>(promise: Promise<T>, signal?: AbortSignal, options?: WithAbortOptions): Promise<T>;