From 07e0e424475d884fee719d19fa5237ca3c70ae0b Mon Sep 17 00:00:00 2001 From: Muhammad Fawwaz Orabi Date: Thu, 30 Nov 2017 10:52:40 +0200 Subject: [PATCH] Add type definitions for shrink-ray --- types/shrink-ray/index.d.ts | 54 ++++++++++++++++++++++++++++ types/shrink-ray/shrink-ray-tests.ts | 6 ++++ types/shrink-ray/tsconfig.json | 22 ++++++++++++ types/shrink-ray/tslint.json | 1 + 4 files changed, 83 insertions(+) create mode 100644 types/shrink-ray/index.d.ts create mode 100644 types/shrink-ray/shrink-ray-tests.ts create mode 100644 types/shrink-ray/tsconfig.json create mode 100644 types/shrink-ray/tslint.json diff --git a/types/shrink-ray/index.d.ts b/types/shrink-ray/index.d.ts new file mode 100644 index 0000000000..a237c298fa --- /dev/null +++ b/types/shrink-ray/index.d.ts @@ -0,0 +1,54 @@ +// Type definitions for shrink-ray 0.1 +// Project: https://github.com/aickin/shrink-ray +// Definitions by: forabi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { RequestHandler, Request, Response } from 'express'; +import * as zlib from 'zlib'; +type FilterFunction = (req: Request, res: Response) => boolean; + +type Options = Partial<{ + cacheSize: number; + threshold: number; + zlib: Partial<{ + /** default: zlib.constants.Z_NO_FLUSH */ + flush?: number; + + /** default: zlib.constants.Z_FINISH */ + finishFlush?: number; + + /** default: 16*1024 */ + chunkSize?: number; + windowBits?: number; + + /** compression only */ + strategy?: number; + + /** deflate/inflate only, empty dictionary by default */ + dictionary?: any; + + /** compression only */ + level: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; + + /** compression only */ + memLevel: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; + }>; + brotli: { + lgblock: number; + lgwin: number; + mode: 0 | 1 | 2; + quality: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11; + }; + filter: FilterFunction; + cache(req: Request, res: Response): boolean; +}>; + +interface CreateMiddleware { + (options?: Options): RequestHandler; + filter: FilterFunction; +} + +declare const createMiddleware: CreateMiddleware; + +export = createMiddleware; diff --git a/types/shrink-ray/shrink-ray-tests.ts b/types/shrink-ray/shrink-ray-tests.ts new file mode 100644 index 0000000000..e221806b88 --- /dev/null +++ b/types/shrink-ray/shrink-ray-tests.ts @@ -0,0 +1,6 @@ +import * as express from 'express'; +import * as shrinkRay from 'shrink-ray'; + +const app = express(); + +app.use(shrinkRay()); diff --git a/types/shrink-ray/tsconfig.json b/types/shrink-ray/tsconfig.json new file mode 100644 index 0000000000..e90ce49102 --- /dev/null +++ b/types/shrink-ray/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shrink-ray-tests.ts" + ] +} diff --git a/types/shrink-ray/tslint.json b/types/shrink-ray/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/shrink-ray/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }