mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-01 03:20:46 +08:00
Merge pull request #19792 from scottharwell/express-brute-redis
Add typings for express-brute-redis
This commit is contained in:
22
types/express-brute-redis/express-brute-redis-tests.ts
Normal file
22
types/express-brute-redis/express-brute-redis-tests.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import express = require("express");
|
||||
import expressbrute = require("express-brute");
|
||||
import expressbruteredis = require("express-brute-redis");
|
||||
|
||||
const store: expressbruteredis = new expressbruteredis({
|
||||
host: "localhost",
|
||||
port: 6379,
|
||||
db: "0"
|
||||
});
|
||||
|
||||
const bruteforce: expressbrute = new expressbrute(store, {
|
||||
failCallback: (req: express.Request, res: express.Response, next: express.NextFunction, validTime: Date) => {
|
||||
// Don't send a message back to the user in production
|
||||
res.send("You cannot submit a request again until: " + validTime);
|
||||
}
|
||||
});
|
||||
|
||||
const app: express.Express = express();
|
||||
|
||||
app.post("/", bruteforce.prevent, (req, res, next) => {
|
||||
res.send("Success!");
|
||||
});
|
||||
48
types/express-brute-redis/index.d.ts
vendored
Normal file
48
types/express-brute-redis/index.d.ts
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// Type definitions for express-brute-redis 0.0
|
||||
// Project: https://github.com/AdamPflug/express-brute-redis
|
||||
// Definitions by: Scott Harwell <https://github.com/scottharwell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { ClientOpts } from "redis";
|
||||
|
||||
/**
|
||||
* @summary Redis store for Express Brute
|
||||
* @class
|
||||
*/
|
||||
declare class express_brute_redis {
|
||||
/**
|
||||
* Default options for the Redis client
|
||||
*/
|
||||
static defaults: ClientOpts;
|
||||
|
||||
/**
|
||||
* @summary constructor
|
||||
* @param options Options to configure the Redis client.
|
||||
*/
|
||||
constructor(options?: ClientOpts, ...args: any[]);
|
||||
|
||||
/**
|
||||
* @summary Sets a key in Redis storage.
|
||||
* @param key
|
||||
* @param value
|
||||
* @param lifetime
|
||||
* @param callback
|
||||
*/
|
||||
set(key: string, value: string, lifetime?: number, callback?: (sender: express_brute_redis) => void): void;
|
||||
|
||||
/**
|
||||
* @summary Gets a key in Redis storage.
|
||||
* @param key
|
||||
* @param callback
|
||||
*/
|
||||
get(key: string, callback?: (err: Error, data: any) => void): void;
|
||||
|
||||
/**
|
||||
* @summary Resets a key in Redis storage.
|
||||
* @param key
|
||||
* @param callback
|
||||
*/
|
||||
reset(key: string, callback?: (err: Error, data: any) => void, ...args: any[]): void;
|
||||
}
|
||||
|
||||
export = express_brute_redis;
|
||||
22
types/express-brute-redis/tsconfig.json
Normal file
22
types/express-brute-redis/tsconfig.json
Normal 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",
|
||||
"express-brute-redis-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/express-brute-redis/tslint.json
Normal file
1
types/express-brute-redis/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user