3.1.6 • Published 2 years ago

@types/koa-json-error v3.1.6

Weekly downloads
1,162
License
MIT
Repository
github
Last release
2 years ago

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

// Type definitions for koa-json-error 3.1
// Project: https://github.com/koajs/json-error
// Definitions by: Mudkip <https://github.com/mudkipme>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

import * as Koa from "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: Wed, 03 Nov 2021 02:01:24 GMT
  • Dependencies: @types/koa
  • Global values: none

Credits

These definitions were written by Mudkip.

3.1.6

2 years ago

3.1.5

2 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

8 years ago

3.1.1

8 years ago

3.1.0

8 years ago

3.0.3

8 years ago

3.0.2

8 years ago

3.0.1

9 years ago