mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 13:00:19 +00:00
add difinitions for koa-compress
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
/// <reference path="../koa/koa.d.ts" />
|
||||
/// <reference path="koa-compress.d.ts" />
|
||||
|
||||
import * as Koa from "koa";
|
||||
import compress = require("koa-compress");
|
||||
|
||||
const app = new Koa();
|
||||
|
||||
app.use(compress({
|
||||
filter: (ctype) => {
|
||||
return /text/i.test(ctype)
|
||||
},
|
||||
threshold: 2048
|
||||
}));
|
||||
|
||||
app.listen(80)
|
||||
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
// Type definitions for koa-compress v2.x
|
||||
// Project: https://github.com/koajs/compress
|
||||
// Definitions by: Jerry Chin <https://github.com/hellopao/>
|
||||
// Definitions: https://github.com/hellopao/DefinitelyTyped
|
||||
|
||||
/* =================== USAGE ===================
|
||||
|
||||
import compress = require("koa-compress");
|
||||
var Koa = require('koa');
|
||||
|
||||
var app = new Koa();
|
||||
app.use(compress());
|
||||
|
||||
=============================================== */
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../koa/koa.d.ts" />
|
||||
|
||||
declare module "koa-compress" {
|
||||
|
||||
import * as Koa from "koa";
|
||||
import * as zlib from "zlib";
|
||||
|
||||
interface ICompressOptions extends zlib.ZlibOptions {
|
||||
/**
|
||||
* An optional function that checks the response content type to decide whether to compress. By default, it uses compressible.
|
||||
*/
|
||||
filter?: (content_type: string) => boolean;
|
||||
|
||||
/**
|
||||
* Minimum response size in bytes to compress. Default 1024 bytes or 1kb.
|
||||
*/
|
||||
threshold?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Compress middleware for Koa
|
||||
*/
|
||||
function compress(options?: ICompressOptions): { (ctx: Koa.Context, next?: () => any): any };
|
||||
|
||||
export = compress;
|
||||
}
|
||||
Reference in New Issue
Block a user