koa-body

  • Version 6.0.1
  • Published
  • 38.2 kB
  • 6 dependencies
  • MIT license

Install

npm i koa-body
yarn add koa-body
pnpm add koa-body

Overview

A Koa body parser middleware. Supports multipart, urlencoded and JSON request bodies.

Index

Variables

variable KoaBodyMiddlewareOptionsSchema

const KoaBodyMiddlewareOptionsSchema: z.ZodObject<
{
patchNode: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
patchKoa: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
jsonLimit: z.ZodDefault<
z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>
>;
formLimit: z.ZodDefault<
z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>
>;
textLimit: z.ZodDefault<
z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>
>;
encoding: z.ZodDefault<z.ZodOptional<z.ZodString>>;
multipart: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
urlencoded: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
text: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
json: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
jsonStrict: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
includeUnparsed: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
parsedMethods: z.ZodDefault<
z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof HttpMethodEnum>, 'many'>>
>;
},
'strip',
z.ZodTypeAny,
{
json: boolean;
encoding: string;
multipart: boolean;
patchNode: boolean;
patchKoa: boolean;
jsonLimit: string | number;
formLimit: string | number;
textLimit: string | number;
urlencoded: boolean;
text: boolean;
jsonStrict: boolean;
includeUnparsed: boolean;
parsedMethods: HttpMethodEnum[];
},
{
json?: boolean | undefined;
encoding?: string | undefined;
multipart?: boolean | undefined;
patchNode?: boolean | undefined;
patchKoa?: boolean | undefined;
jsonLimit?: string | number | undefined;
formLimit?: string | number | undefined;
textLimit?: string | number | undefined;
urlencoded?: boolean | undefined;
text?: boolean | undefined;
jsonStrict?: boolean | undefined;
includeUnparsed?: boolean | undefined;
parsedMethods?: HttpMethodEnum[] | undefined;
}
>;

    Functions

    function koaBody

    koaBody: (options?: Partial<KoaBodyMiddlewareOptions>) => Middleware;

      Enums

      enum HttpMethodEnum

      enum HttpMethodEnum {
      POST = 'POST',
      GET = 'GET',
      PUT = 'PUT',
      PATCH = 'PATCH',
      DELETE = 'DELETE',
      HEAD = 'HEAD',
      }

        member DELETE

        DELETE = 'DELETE'

          member GET

          GET = 'GET'

            member HEAD

            HEAD = 'HEAD'

              member PATCH

              PATCH = 'PATCH'

                member POST

                POST = 'POST'

                  member PUT

                  PUT = 'PUT'

                    Type Aliases

                    type ExtendedFormidableOptions

                    type ExtendedFormidableOptions = FormidableOptions & {
                    onFileBegin?: (name: string, file: File) => void;
                    };

                      type HttpMethod

                      type HttpMethod = z.infer<typeof HttpMethod>;

                        type KoaBodyDirectOptions

                        type KoaBodyDirectOptions = z.infer<typeof KoaBodyMiddlewareOptionsSchema>;

                          type KoaBodyMiddlewareOptions

                          type KoaBodyMiddlewareOptions = KoaBodyDirectOptions & {
                          onError?: (err: Error, ctx: Context) => void;
                          formidable?: ExtendedFormidableOptions;
                          queryString?: CoBodyOptions['queryString'];
                          };

                            Package Files (2)

                            Dependencies (6)

                            Dev Dependencies (14)

                            Peer Dependencies (0)

                            No peer dependencies.

                            Badge

                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/koa-body.

                            • Markdown
                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/koa-body)
                            • HTML
                              <a href="https://www.jsdocs.io/package/koa-body"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>