npm.io
3.1.7 • Published 11 months ago

@types/koa-json-error

Licence
MIT
Version
3.1.7
Deps
1
Size
4 kB
Vulns
0
Weekly
0
Stars
51.4K

Installation

npm install --save @types/koa-json-error

Summary

This package contains type definitions for koa-json-error (https://github.com/koajs/json-error).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-json-error.

index.d.ts

import Koa = require("koa");

type JSONError = Error & { status: number };

interface JSONErrorOptions {
    /**
     * Perform some task before calling `options.format`. Must be a function with the original err as its only argument.
     */
    preFormat?(err: JSONError): any;

    /**
     * Runs inmediatly after `options.preFormat`. It receives two arguments: the original `err` and the output of     `options.preFormat`. It should `return` a newly formatted error.
     */
    format?(err: JSONError, obj: any): any;

    /**
     * Runs inmediatly after `options.format`. It receives two arguments: the original `err` and the output of   `options.format`.   It should `return` a newly formatted error.
     */
    postFormat?(err: JSONError, obj: any): any;
}

/**
 * Error handler for pure Koa 2.0.0+ JSON apps
 */
declare function jsonError(options?: JSONErrorOptions): Koa.Middleware;

declare namespace jsonError {}
export = jsonError;

Additional Details

  • Last updated: Fri, 24 Oct 2025 0441 GMT
  • Dependencies: @types/koa

Credits

These definitions were written by Mudkip.