Add IORedis and redisURL to rate-limit-redis (#43070)

* Update to support IORedis and redisURL to match rate-limit-redis 1.7.0

* Fix lint issue
This commit is contained in:
Austin Beer 2020-03-12 19:12:25 -06:00 committed by GitHub
parent a806d97668
commit 6e2941256d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -1,18 +1,21 @@
// Type definitions for rate-limit-redis 1.6
// Type definitions for rate-limit-redis 1.7
// Project: https://github.com/wyattjoh/rate-limit-redis#readme
// Definitions by: Chris Suich <https://github.com/csuich2>
// Connor love <https://github.com/dotconnor>
// Connor Love <https://github.com/dotconnor>
// Austin Beer <https://github.com/austin-beer>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
import { RedisClient } from 'redis';
import IORedis = require('ioredis');
import { Store } from 'express-rate-limit';
interface RedisStoreOptions {
expiry?: number;
prefix?: string;
resetExpiryOnChange?: boolean;
client?: RedisClient;
client?: RedisClient | IORedis.Redis;
redisURL?: string;
}
declare var RedisStore: {

View File

@ -1,4 +1,5 @@
import { RedisClient } from 'redis';
import IORedis = require('ioredis');
import RedisStore from 'rate-limit-redis';
import { Store } from 'express-rate-limit';
@ -26,3 +27,13 @@ store = new RedisStore({
store = new RedisStore({
client: new RedisClient({}),
});
// $ExpectType Store
store = new RedisStore({
client: new IORedis({}),
});
// $ExpectType Store
store = new RedisStore({
redisURL: 'redis://localhost:6379',
});