From 20f3713e872eb9b17a3c42a676d7f3733b37dab5 Mon Sep 17 00:00:00 2001 From: Peter Safranek Date: Fri, 17 Mar 2017 22:19:31 -0700 Subject: [PATCH 1/3] Add typings for koa-cache-control. --- koa-cache-control/index.d.ts | 23 ++++++++++++++++++++ koa-cache-control/koa-cache-control-tests.ts | 19 ++++++++++++++++ koa-cache-control/tsconfig.json | 22 +++++++++++++++++++ koa-cache-control/tslint.json | 1 + 4 files changed, 65 insertions(+) create mode 100644 koa-cache-control/index.d.ts create mode 100644 koa-cache-control/koa-cache-control-tests.ts create mode 100644 koa-cache-control/tsconfig.json create mode 100644 koa-cache-control/tslint.json diff --git a/koa-cache-control/index.d.ts b/koa-cache-control/index.d.ts new file mode 100644 index 0000000000..19329fcfec --- /dev/null +++ b/koa-cache-control/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for koa-cache-control 2.0 +// Project: https://github.com/DaMouse404/koa-cache-control +// Definitions by: Peter Safranek +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as Koa from "koa"; + +declare function cacheControl(options?: { + private?: boolean; + public?: boolean; + noStore?: boolean; + noCache?: boolean; + noTransform?: boolean; + mustRevalidate?: boolean; + staleIfError?: number; + staleWhileRevalidate?: number; + maxAge?: number; + sMaxAge?: number; +}): Koa.Middleware; + +declare namespace cacheControl {} + +export = cacheControl; diff --git a/koa-cache-control/koa-cache-control-tests.ts b/koa-cache-control/koa-cache-control-tests.ts new file mode 100644 index 0000000000..c99f4fe862 --- /dev/null +++ b/koa-cache-control/koa-cache-control-tests.ts @@ -0,0 +1,19 @@ +import * as Koa from "koa"; +import * as cacheControl from "koa-cache-control"; + +const app = new Koa(); + +app.use(cacheControl()); +app.use(cacheControl({})); +app.use(cacheControl({ + private: true, + public: true, + noStore: true, + noCache: true, + noTransform: true, + mustRevalidate: true, + staleIfError: 0, + staleWhileRevalidate: 0, + maxAge: 0, + sMaxAge: 0, +})); diff --git a/koa-cache-control/tsconfig.json b/koa-cache-control/tsconfig.json new file mode 100644 index 0000000000..ae4aea7b85 --- /dev/null +++ b/koa-cache-control/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "koa-cache-control-tests.ts" + ] +} diff --git a/koa-cache-control/tslint.json b/koa-cache-control/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/koa-cache-control/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 50669334d91c9b06911a140094e2c7531a777972 Mon Sep 17 00:00:00 2001 From: Peter Safranek Date: Fri, 17 Mar 2017 22:34:33 -0700 Subject: [PATCH 2/3] Add stricter linting per the README. --- tslint.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tslint.json b/tslint.json index 6b04ae7f36..e2c0a2d3a1 100644 --- a/tslint.json +++ b/tslint.json @@ -1 +1,7 @@ -{ "extends": "./node_modules/types-publisher/tslint-definitions.json" } \ No newline at end of file +{ + "extends": "./node_modules/types-publisher/tslint-definitions.json", + + "noImplicitAny": "true", + "noImplicitThis": "true", + "strictNullChecks": "true" +} From 57093f088c433028fed9948db58255ad297d9625 Mon Sep 17 00:00:00 2001 From: Peter Safranek Date: Fri, 17 Mar 2017 22:42:17 -0700 Subject: [PATCH 3/3] Add strict lint rules to correct tslint.json. --- koa-cache-control/tslint.json | 8 +++++++- tslint.json | 8 +------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/koa-cache-control/tslint.json b/koa-cache-control/tslint.json index 377cc837d4..eb88e553a5 100644 --- a/koa-cache-control/tslint.json +++ b/koa-cache-control/tslint.json @@ -1 +1,7 @@ -{ "extends": "../tslint.json" } +{ + "extends": "../tslint.json", + + "noImplicitAny": "true", + "noImplicitThis": "true", + "strictNullChecks": "true" +} diff --git a/tslint.json b/tslint.json index e2c0a2d3a1..7847d36674 100644 --- a/tslint.json +++ b/tslint.json @@ -1,7 +1 @@ -{ - "extends": "./node_modules/types-publisher/tslint-definitions.json", - - "noImplicitAny": "true", - "noImplicitThis": "true", - "strictNullChecks": "true" -} +{ "extends": "./node_modules/types-publisher/tslint-definitions.json" }