import type { ServerAdapterInitialContext } from '../types.js';
import type { ServerAdapterPlugin } from './types.js';
export interface RequestDeadlineOptions<TServerContext = {}> {
    /**
     * The timeout in milliseconds after which the request should be considered as "timed out" and
     * the deadline response should be produced.
     *
     * The deadline timeout is different from Node's `requestTimeout` or `headersTimeout` as it is not
     * related to the time spent _waiting_ for the request to be received or the headers to be parsed.
     * Instead, it is related to the total time spent processing the request, including the time spent
     * in the request handler and all the plugins hooks.
     */
    timeout: number;
    /**
     * A function that produces the response to be sent when the deadline is reached. It receives the
     * original request and the server context as parameters, so you can use them to produce a more
     * informed response.
     */
    response: (request: Request, ctx: TServerContext & ServerAdapterInitialContext) => Response;
}
/**
 * A plugin that allows you to set a deadline for each request. If the request takes longer than
 * the specified timeout, the plugin will produce a response using the provided response factory function.
 *
 * This plugin is useful to prevent requests from taking too long and to provide a better experience
 * for the clients by sending a timely response when the server is under heavy load or when there are
 * long-running requests.
 *
 * This plugin also aborts the request signal when the deadline is reached. This means that if the
 * request handler, or any of the plugins hooks, are listening to the request signal, they will be able
 * to react to the deadline being reached and perform any necessary cleanup operations.
 */
export declare function useRequestDeadline<TServerContext = {}>(opts: RequestDeadlineOptions<TServerContext>): ServerAdapterPlugin<TServerContext>;
