mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add typings for rate-limit-redis (#39036)
* Add typings for rate-limit-redis * Limit rate-limit-redis to TS 2.3 b/c of express-rate-limit requirement * Bump rate-limit-redis to TS 2.7
This commit is contained in:
parent
dc02437227
commit
e72d59512c
19
types/rate-limit-redis/index.d.ts
vendored
Normal file
19
types/rate-limit-redis/index.d.ts
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
// Type definitions for rate-limit-redis 1.6
|
||||
// Project: https://github.com/wyattjoh/rate-limit-redis#readme
|
||||
// Definitions by: Chris Suich <https://github.com/csuich2>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
import { RedisClient } from 'redis';
|
||||
import { Store } from 'express-rate-limit';
|
||||
|
||||
interface RedisStoreOptions {
|
||||
expiry?: number;
|
||||
prefix?: string;
|
||||
resetExpiryOnChange?: boolean;
|
||||
client?: RedisClient;
|
||||
}
|
||||
|
||||
declare function RedisStore(options?: RedisStoreOptions): Store;
|
||||
|
||||
export = RedisStore;
|
||||
6
types/rate-limit-redis/package.json
Normal file
6
types/rate-limit-redis/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"express-rate-limit": ">=3.4.0"
|
||||
}
|
||||
}
|
||||
28
types/rate-limit-redis/rate-limit-redis-tests.ts
Normal file
28
types/rate-limit-redis/rate-limit-redis-tests.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { RedisClient } from 'redis';
|
||||
import RedisStore from 'rate-limit-redis';
|
||||
import { Store } from 'express-rate-limit';
|
||||
|
||||
let store: Store;
|
||||
|
||||
// $ExpectType Store
|
||||
store = RedisStore();
|
||||
|
||||
// $ExpectType Store
|
||||
store = RedisStore({
|
||||
expiry: 1000,
|
||||
});
|
||||
|
||||
// $ExpectType Store
|
||||
store = RedisStore({
|
||||
prefix: 'types',
|
||||
});
|
||||
|
||||
// $ExpectType Store
|
||||
store = RedisStore({
|
||||
resetExpiryOnChange: false,
|
||||
});
|
||||
|
||||
// $ExpectType Store
|
||||
store = RedisStore({
|
||||
client: new RedisClient({}),
|
||||
});
|
||||
24
types/rate-limit-redis/tsconfig.json
Normal file
24
types/rate-limit-redis/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"rate-limit-redis-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/rate-limit-redis/tslint.json
Normal file
1
types/rate-limit-redis/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user