@types/express-mung
TypeScript icon, indicating that this package has built-in type declarations

0.5.5 • Public • Published

Installation

npm install --save @types/express-mung

Summary

This package contains type definitions for express-mung (https://github.com/richardschneider/express-mung).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/express-mung.

/// <reference types="node"/>

import { ErrorRequestHandler, Request, RequestHandler, Response } from "express";

export type Transform = (body: {}, request: Request, response: Response) => any;
export type TransformAsync = (body: {}, request: Request, response: Response) => PromiseLike<any>;
export type TransformHeader = (request: Request, response: Response) => any;
export type TransformHeaderAsync = (request: Request, response: Response) => PromiseLike<any>;
export type TransformChunk = (
    chunk: string | Buffer,
    encoding: string | null,
    request: Request,
    response: Response,
) => string | Buffer;

export interface Options {
    mungError: boolean;
}

/**
 * Transform the JSON body of the response.
 * @param fn A transformation function.
 * @param options json options.
 * @return Middleware to transform the body
 */
export function json(fn: Transform, options?: Options): RequestHandler;

/**
 * Asynchronously transform the JSON body of the response.
 * @param fn A transformation function.
 * @param options jsonAsync options.
 * @return Middleware to transform the body
 */
export function jsonAsync(fn: TransformAsync, options?: Options): RequestHandler;

/**
 * Transform the HTTP headers of the response.
 * @param fn A transformation function.
 * @return Middleware to transform the headers
 */
export function headers(fn: TransformHeader): RequestHandler;

/**
 * Asynchronously transform the HTTP headers of the response.
 * @param fn A transformation function.
 * @return Middleware to transform the headers
 */
export function headersAsync(fn: TransformHeaderAsync): RequestHandler;

/**
 * Transform chunks as they are written to the response
 * @param fn A transformation function.
 * @param options Write options.
 * @return Middleware to transform chunks.
 */
export function write(fn: TransformChunk, options?: Options): RequestHandler;

/**
 * Override the default onError handler.
 * @see {ErrorRequestHandler}
 */
export let onError: ErrorRequestHandler;

Additional Details

Credits

These definitions were written by Cyril Schumacher, and Levi Bostian.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/express-mung

Weekly Downloads

13,143

Version

0.5.5

License

MIT

Unpacked Size

6.98 kB

Total Files

5

Last publish

Collaborators

  • types