diff --git a/types/kompression/index.d.ts b/types/kompression/index.d.ts new file mode 100644 index 0000000000..5f352c795d --- /dev/null +++ b/types/kompression/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for kompression 1.0 +// Project: https://github.com/tuananh/kompression +// Definitions by: Aankhen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import koa = require("koa"); + +export = kompression; + +declare function kompression(options?: Kompression.Options): koa.Middleware; + +declare namespace Kompression { + interface Options { + filter?: (contentType: string) => boolean; + threshold?: number; + } +} diff --git a/types/kompression/kompression-tests.ts b/types/kompression/kompression-tests.ts new file mode 100644 index 0000000000..798900d218 --- /dev/null +++ b/types/kompression/kompression-tests.ts @@ -0,0 +1,22 @@ +import Koa = require("koa"); +import compress = require("kompression"); + +const app = new Koa(); + +app.use( + compress() +); + +app.use( + compress({}) +); + +// based on README +app.use( + compress({ + filter(contentType) { + return /text/i.test(contentType); + }, + threshold: 2048, + }) +); diff --git a/types/kompression/tsconfig.json b/types/kompression/tsconfig.json new file mode 100644 index 0000000000..fbb787ef8c --- /dev/null +++ b/types/kompression/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "kompression-tests.ts" + ] +} diff --git a/types/kompression/tslint.json b/types/kompression/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/kompression/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }