adds typings for koa-ratelimit-lru package

This commit is contained in:
Daniel Byrne
2018-11-16 10:55:47 -08:00
parent 44650cfbe7
commit 2641b36c8d
4 changed files with 66 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for koa-ratelimit-lru 1.0
// Project: https://github.com/Dreamacro/koa-ratelimit-lru
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// 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;
@@ -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);
+23
View File
@@ -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"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}