mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
adds typings for koa-ratelimit-lru package
This commit is contained in:
Vendored
+28
@@ -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);
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user