import { Options as FormidableOptions } from "formidable";
import { DefaultContext, DefaultState, Next, ParameterizedContext } from "koa";
declare function KoaBetterBody(
options?: KoaBetterBody.Options,
): KoaBetterBody.Body;
declare namespace KoaBetterBody {
interface Options extends FormidableOptions {
/**
* {
*
multipart: ['multipart/form-data'],
*
text: ['text/*'],
*
form: ['application/x-www-form-urlencoded'],
*
json: [
*
'application/json',
*
'application/json-patch+json',
*
'application/vnd.api+json',
*
'application/csp-report'
*
],
*
buffer: ['text/*']
* }
*/
extendTypes?: Record & {
custom?: string | string[];
};
/**
* @default false
*/
fields?: boolean | string;
/**
* @default false
*/
files?: boolean | string;
/**
* @default true
*/
multipart?: boolean;
/**
* @default false
*/
textLimit?: string;
/**
* @default false
*/
formLimit?: string;
/**
* @default false
*/
jsonLimit?: string;
/**
* @default true
*/
jsonStrict?: boolean;
/**
* @default () => false
*/
detectJSON?: (
ctx: ParameterizedContext,
) => boolean;
/**
* @default false
*/
bufferLimit?: string;
/**
* @default false
*/
buffer?: boolean;
/**
* @default true
*/
strict?: boolean;
/**
* @default '&'
*/
delimiter?: string;
/**
* @default require('querystring').unescape
*/
decodeURIComponent?: (query: string) => string;
/**
* @default 1000
*/
maxKeys?: number; // default: 1000
/**
* @deprecated use formLimit instead
* @default config.formLimit
*/
urlencodedLimit?: string;
/**
* @deprecated use delimiter instead
* @default config.delimiter
*/
sep?: string;
/**
* @default undefined
*/
onError?: (
err: any,
ctx: ParameterizedContext,
) => void;
/**
* @default undefined
*/
handler?: (
ctx: ParameterizedContext,
options: Options,
next: Next,
) => void;
}
type Body = (next: Next) => Generator;
}
export = KoaBetterBody;