UNPKG

@busy-hour/blaze

Version:

<h1 align='center'>🔥 Blaze</h1> <div align='center'> An event driven framework for 🔥 Hono.js </div>

32 lines (31 loc) • 827 B
import type { Context as HonoCtx, Next as HonoNext } from 'hono'; import type { ActionHandler } from '../types/action'; export interface BodyLimitOptions { maxSize: number; onError?: ActionHandler; } /** * Limit request body size * @example * ```ts * const action = BlazeCreator.action({ * rest: 'POST /', * middlewares: [ * [ * 'ALL', * bodyLimit({ * maxSize: 100 * 1024, // 100kb * async onError() { * throw new BlazeError('Payload too large', 413) * } * }) * ] * ], * async handler(ctx) { * /// Do something with the request * /// when the request size is less than 100kb * } * }) * ``` */ export declare function bodyLimit(options: BodyLimitOptions): (honoCtx: HonoCtx, next: HonoNext) => Promise<void | Response>;