UNPKG

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