# @types/koa-xml-body

> TypeScript definitions for koa-xml-body

Latest version **2.2.4** (published 2025-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/koa-xml-body
pnpm add @types/koa-xml-body
yarn add @types/koa-xml-body
bun add @types/koa-xml-body
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.2.4 |
| Published | 2025-10-24 |
| First published | 2018-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51445 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/koa-xml-body
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-xml-body
- npm.io page: https://npm.io/package/@types/koa-xml-body

## Dependencies (2)

- [@types/koa](https://npm.io/package/@types/koa.md) *
- [@types/xml2js](https://npm.io/package/@types/xml2js.md) *

## Recent versions

- 2.2.4 (latest) — 2025-10-24
- 2.2.3 (ts5.1) — 2023-11-07
- 2.2.0 (ts3.8) — 2021-08-29
- 2.0.3 (ts3.6) — 2021-07-08
- 2.0.2 (ts3.5) — 2020-11-19
- 2.0.1 (ts3.4) — 2020-05-15
- 2.0.0 (ts2.3) — 2018-04-25
- 2.2.2 — 2023-10-18
- 2.2.1 — 2023-09-14

## README

# Installation
> `npm install --save @types/koa-xml-body`

# Summary
This package contains type definitions for koa-xml-body (https://github.com/creeperyang/koa-xml-body).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-xml-body.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-xml-body/index.d.ts)
````ts
/* =================== USAGE ===================

    import Koa = require('koa');
    import KoaXmlBody = require('koa-xml-body');

    const app = new Koa();
    app.use(KoaXmlBody({
        onerror: (err, ctx) => {
            ctx.throw(err.message);
        }
    }));

 =============================================== */

import Koa = require("koa");

import { ParserOptions as Xml2jsOptions } from "xml2js";

declare module "koa" {
    interface Request {
        body: any;
    }
}

declare function bodyParser(opts?: {
    // Key used for decoding when to parse ctx.request; default is 'body'
    key?: string;
    // requested encoding. Default is utf8. If not set, the lib will retrive it from content-type(such as content-type:application/xml;charset=gb2312).
    encoding?: string;
    // limit of the body. If the body ends up being larger than this limit, a 413 error code is returned. Default is 1mb.
    limit?: number;
    // length of the body. When content-length is found, it will be overwritten automatically.
    length?: number;
    // error handler. Default is a noop function. It means it will eat the error silently. You can config it to customize the response.
    onerror?: (err: Error, ctx: Koa.Context) => void;
    // options which will be used to parse xml. Default is {}. See xml2js Options for details.
    xmlOptions?: Xml2jsOptions;
}): Koa.Middleware;

declare namespace bodyParser {}
export = bodyParser;

````

### Additional Details
 * Last updated: Fri, 24 Oct 2025 04:02:41 GMT
 * Dependencies: [@types/koa](https://npmjs.com/package/@types/koa), [@types/xml2js](https://npmjs.com/package/@types/xml2js)

# Credits
These definitions were written by [Ulf Winkelvos](https://github.com/uwinkelvos).

---
_Source: https://npm.io/package/@types/koa-xml-body · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
