UNPKG

1.84 kBTypeScriptView Raw
1// Type definitions for koa-compress v4.x
2// Project: https://github.com/koajs/compress
3// Definitions by: Jerry Chin <https://github.com/hellopao>
4// Joel Gallant <https://github.com/joelgallant>
5// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6// TypeScript Version: 2.3
7
8/* =================== USAGE ===================
9
10 import compress = require("koa-compress");
11 var Koa = require('koa');
12
13 var app = new Koa();
14 app.use(compress());
15
16 =============================================== */
17/// <reference types="node" />
18/// <reference types="koa" />
19
20import * as Koa from "koa";
21import * as zlib from "zlib";
22
23/**
24 * Compress middleware for Koa
25 */
26declare function koaCompress(options?: koaCompress.CompressOptions): Koa.Middleware;
27
28declare namespace koaCompress {
29 export interface CompressOptions {
30 /**
31 * An optional function that checks the response content type to decide whether to compress. By default, it uses compressible.
32 */
33 filter?: ((mimeType: string) => boolean) | undefined;
34
35 /**
36 * Minimum response size in bytes to compress. Default 1024 bytes or 1kb.
37 */
38 threshold?: number | string | undefined;
39
40 /**
41 * An optional string, which specifies what encoders to use for requests
42 * without Accept-Encoding. Default: 'idenity'.
43 */
44 defaultEncoding?: string | undefined
45
46 /**
47 * Options for brotli compression.
48 */
49 br?: zlib.BrotliOptions | false | undefined;
50
51 /**
52 * Options for gzip compression.
53 */
54 gzip?: zlib.ZlibOptions | false | undefined;
55
56 /**
57 * Options for deflate compression.
58 */
59 deflate?: zlib.ZlibOptions | false | undefined;
60 }
61}
62
63export = koaCompress;
64
\No newline at end of file