Files
SnowLuma/.pnpm-store/v11/files/c7/3f239290b14fb94c30141d6c6421e3bded968ca8b7094854cc5e1c5ef01ed30a589d9ca26db5ee2b602feb7fe29a77f6932dcd8dadf82e1250973a20152fdd
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

29 lines
1.1 KiB
Plaintext

import { MiddlewareHandler } from "../../types.js";
import { Context } from "../../context.js";
import { HTTPException } from "../../http-exception.js";
//#region src/middleware/timeout/index.d.ts
export type HTTPExceptionFunction = (context: Context) => HTTPException;
/**
* Timeout Middleware for Hono.
*
* @param {number} duration - The timeout duration in milliseconds.
* @param {HTTPExceptionFunction | HTTPException} [exception=defaultTimeoutException] - The exception to throw when the timeout occurs. Can be a function that returns an HTTPException or an HTTPException object.
* @returns {MiddlewareHandler} The middleware handler function.
*
* @example
* ```ts
* const app = new Hono()
*
* app.use(
* '/long-request',
* timeout(5000) // Set timeout to 5 seconds
* )
*
* app.get('/long-request', async (c) => {
* await someLongRunningFunction()
* return c.text('Completed within time limit')
* })
* ```
*/
export declare const timeout: (duration: number, exception?: HTTPExceptionFunction | HTTPException) => MiddlewareHandler;
//#endregion