1 | import type { File, Options as FormidableOptions } from 'formidable';
|
2 | import type { Options as CoBodyOptions } from 'co-body';
|
3 | import type { Context } from 'koa';
|
4 | import { z } from 'zod';
|
5 | export declare enum HttpMethodEnum {
|
6 | POST = "POST",
|
7 | GET = "GET",
|
8 | PUT = "PUT",
|
9 | PATCH = "PATCH",
|
10 | DELETE = "DELETE",
|
11 | HEAD = "HEAD"
|
12 | }
|
13 | declare const HttpMethod: z.ZodNativeEnum<typeof HttpMethodEnum>;
|
14 | export declare type HttpMethod = z.infer<typeof HttpMethod>;
|
15 | export declare type ExtendedFormidableOptions = FormidableOptions & {
|
16 | onFileBegin?: (name: string, file: File) => void;
|
17 | };
|
18 | export declare const KoaBodyMiddlewareOptionsSchema: z.ZodObject<{
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 | patchNode: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 | patchKoa: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
31 | |
32 |
|
33 |
|
34 | jsonLimit: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
|
35 | |
36 |
|
37 |
|
38 | formLimit: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
|
39 | |
40 |
|
41 |
|
42 | textLimit: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
|
43 | |
44 |
|
45 |
|
46 | encoding: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
47 | |
48 |
|
49 |
|
50 | multipart: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
51 | |
52 |
|
53 |
|
54 | urlencoded: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
55 | |
56 |
|
57 |
|
58 | text: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
59 | |
60 |
|
61 |
|
62 | json: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
63 | |
64 |
|
65 |
|
66 | jsonStrict: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
67 | |
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | includeUnparsed: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
82 | |
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | parsedMethods: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof HttpMethodEnum>, "many">>>;
|
92 | }, "strip", z.ZodTypeAny, {
|
93 | json: boolean;
|
94 | encoding: string;
|
95 | multipart: boolean;
|
96 | patchNode: boolean;
|
97 | patchKoa: boolean;
|
98 | jsonLimit: string | number;
|
99 | formLimit: string | number;
|
100 | textLimit: string | number;
|
101 | urlencoded: boolean;
|
102 | text: boolean;
|
103 | jsonStrict: boolean;
|
104 | includeUnparsed: boolean;
|
105 | parsedMethods: HttpMethodEnum[];
|
106 | }, {
|
107 | json?: boolean | undefined;
|
108 | encoding?: string | undefined;
|
109 | multipart?: boolean | undefined;
|
110 | patchNode?: boolean | undefined;
|
111 | patchKoa?: boolean | undefined;
|
112 | jsonLimit?: string | number | undefined;
|
113 | formLimit?: string | number | undefined;
|
114 | textLimit?: string | number | undefined;
|
115 | urlencoded?: boolean | undefined;
|
116 | text?: boolean | undefined;
|
117 | jsonStrict?: boolean | undefined;
|
118 | includeUnparsed?: boolean | undefined;
|
119 | parsedMethods?: HttpMethodEnum[] | undefined;
|
120 | }>;
|
121 | export declare type KoaBodyDirectOptions = z.infer<typeof KoaBodyMiddlewareOptionsSchema>;
|
122 | export declare type KoaBodyMiddlewareOptions = KoaBodyDirectOptions & {
|
123 | onError?: (err: Error, ctx: Context) => void;
|
124 | formidable?: ExtendedFormidableOptions;
|
125 | queryString?: CoBodyOptions['queryString'];
|
126 | };
|
127 | export {};
|