diff --git a/types/koa-ratelimit-lru/index.d.ts b/types/koa-ratelimit-lru/index.d.ts new file mode 100644 index 0000000000..f6c560f16a --- /dev/null +++ b/types/koa-ratelimit-lru/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for koa-ratelimit-lru 1.0 +// Project: https://github.com/Dreamacro/koa-ratelimit-lru +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Middleware } from 'koa'; + +declare namespace rateLimit { + interface Options { + readonly duration?: number; + readonly max?: number; + readonly prefix?: string; + readonly store?: any; // lru-cache ? + readonly rate?: number; + readonly id?: string; + readonly headers?: { + readonly remaining?: string; + readonly reset?: string; + readonly total?: string; + }; + readonly errorMessage?: string; + } + } + +declare function rateLimit(options?: rateLimit.Options): Middleware; + +export = rateLimit; diff --git a/types/koa-ratelimit-lru/koa-ratelimit-lru-tests.ts b/types/koa-ratelimit-lru/koa-ratelimit-lru-tests.ts new file mode 100644 index 0000000000..84759cb43b --- /dev/null +++ b/types/koa-ratelimit-lru/koa-ratelimit-lru-tests.ts @@ -0,0 +1,12 @@ +import Koa = require('koa'); +import rateLimit = require('koa-ratelimit-lru'); + +const app = new Koa(); + +app.use(rateLimit({})); + +app.use(async context => { + context.body = "Hello"; +}); + +app.listen(2000); diff --git a/types/koa-ratelimit-lru/tsconfig.json b/types/koa-ratelimit-lru/tsconfig.json new file mode 100644 index 0000000000..7f285be8e3 --- /dev/null +++ b/types/koa-ratelimit-lru/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "koa-ratelimit-lru-tests.ts" + ] +} diff --git a/types/koa-ratelimit-lru/tslint.json b/types/koa-ratelimit-lru/tslint.json new file mode 100644 index 0000000000..6fafe521cb --- /dev/null +++ b/types/koa-ratelimit-lru/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" + }