Add type definitions for shrink-ray

This commit is contained in:
Muhammad Fawwaz Orabi
2017-11-30 10:52:40 +02:00
parent 420f99c1dc
commit 07e0e42447
4 changed files with 83 additions and 0 deletions

54
types/shrink-ray/index.d.ts vendored Normal file
View File

@@ -0,0 +1,54 @@
// Type definitions for shrink-ray 0.1
// Project: https://github.com/aickin/shrink-ray
// Definitions by: forabi <https://github.com/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;

View File

@@ -0,0 +1,6 @@
import * as express from 'express';
import * as shrinkRay from 'shrink-ray';
const app = express();
app.use(shrinkRay());

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }