1 | # Installation
|
2 | > `npm install --save @types/koa-compress`
|
3 |
|
4 | # Summary
|
5 | This package contains type definitions for koa-compress (https://github.com/koajs/compress).
|
6 |
|
7 | # Details
|
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-compress.
|
9 | ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-compress/index.d.ts)
|
10 | ````ts
|
11 | // Type definitions for koa-compress v4.x
|
12 | // Project: https://github.com/koajs/compress
|
13 | // Definitions by: Jerry Chin <https://github.com/hellopao>
|
14 | // Joel Gallant <https://github.com/joelgallant>
|
15 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
16 | // TypeScript Version: 2.3
|
17 |
|
18 | /* =================== USAGE ===================
|
19 |
|
20 | import compress = require("koa-compress");
|
21 | var Koa = require('koa');
|
22 |
|
23 | var app = new Koa();
|
24 | app.use(compress());
|
25 |
|
26 | =============================================== */
|
27 | /// <reference types="node" />
|
28 | /// <reference types="koa" />
|
29 |
|
30 | import * as Koa from "koa";
|
31 | import * as zlib from "zlib";
|
32 |
|
33 | /**
|
34 | * Compress middleware for Koa
|
35 | */
|
36 | declare function koaCompress(options?: koaCompress.CompressOptions): Koa.Middleware;
|
37 |
|
38 | declare namespace koaCompress {
|
39 | export interface CompressOptions {
|
40 | /**
|
41 | * An optional function that checks the response content type to decide whether to compress. By default, it uses compressible.
|
42 | */
|
43 | filter?: ((mimeType: string) => boolean) | undefined;
|
44 |
|
45 | /**
|
46 | * Minimum response size in bytes to compress. Default 1024 bytes or 1kb.
|
47 | */
|
48 | threshold?: number | string | undefined;
|
49 |
|
50 | /**
|
51 | * An optional string, which specifies what encoders to use for requests
|
52 | * without Accept-Encoding. Default: 'idenity'.
|
53 | */
|
54 | defaultEncoding?: string | undefined
|
55 |
|
56 | /**
|
57 | * Options for brotli compression.
|
58 | */
|
59 | br?: zlib.BrotliOptions | false | undefined;
|
60 |
|
61 | /**
|
62 | * Options for gzip compression.
|
63 | */
|
64 | gzip?: zlib.ZlibOptions | false | undefined;
|
65 |
|
66 | /**
|
67 | * Options for deflate compression.
|
68 | */
|
69 | deflate?: zlib.ZlibOptions | false | undefined;
|
70 | }
|
71 | }
|
72 |
|
73 | export = koaCompress;
|
74 |
|
75 | ````
|
76 |
|
77 | ### Additional Details
|
78 | * Last updated: Fri, 09 Jul 2021 02:32:32 GMT
|
79 | * Dependencies: [@types/koa](https://npmjs.com/package/@types/koa), [@types/node](https://npmjs.com/package/@types/node)
|
80 | * Global values: none
|
81 |
|
82 | # Credits
|
83 | These definitions were written by [Jerry Chin](https://github.com/hellopao), and [Joel Gallant](https://github.com/joelgallant).
|
84 |
|
\ | No newline at end of file |