2.2.3 • Published 6 months ago
@types/koa-xml-body v2.2.3
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
// Type definitions for koa-xml-body 2.2
// Project: https://github.com/creeperyang/koa-xml-body
// Definitions by: Ulf Winkelvos <https://github.com/uwinkelvos>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.5
/* =================== 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 * as Koa from "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: Sun, 29 Aug 2021 14:31:19 GMT
- Dependencies: @types/koa, @types/xml2js
- Global values: none
Credits
These definitions were written by Ulf Winkelvos.