Skip to content

Commit cfbf8b9

Browse files
committed
refactored redis options in tests to work with ioredis
1 parent 82bd25b commit cfbf8b9

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/middleware/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import RedisClientOptions from 'ioredis';
1+
import Redis, { RedisOptions } from 'ioredis';
22
import { Request, Response, NextFunction, RequestHandler } from 'express';
33
import { GraphQLSchema } from 'graphql/type/schema';
44
import { defaultTypeWeightsConfig } from '../analysis/buildTypeWeights';
@@ -24,7 +24,7 @@ export function expressRateLimiter(
2424
rateLimiter: RateLimiterSelection,
2525
rateLimiterOptions: RateLimiterOptions,
2626
schema: GraphQLSchema,
27-
redisClientOptions: RedisClientOptions,
27+
redisClientOptions: RedisOptions,
2828
typeWeightConfig: TypeWeightConfig = defaultTypeWeightsConfig
2929
): RequestHandler {
3030
// TODO: Set 'timestamp' on res.locals to record when the request is received in UNIX format. HTTP does not inlude this.

test/middleware/express.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ xdescribe('Express Middleware tests', () => {
101101
'TOKEN_BUCKET',
102102
{ refillRate: 1, bucketSize: 10 },
103103
schema,
104-
{ url: '' }
104+
{ path: '' }
105105
)
106106
).not.toThrow();
107107
});
@@ -112,7 +112,7 @@ xdescribe('Express Middleware tests', () => {
112112
'LEAKY_BUCKET',
113113
{ refillRate: 1, bucketSize: 10 }, // FIXME: Replace with valid params
114114
schema,
115-
{ url: '' }
115+
{ path: '' }
116116
)
117117
).not.toThrow();
118118
});
@@ -123,7 +123,7 @@ xdescribe('Express Middleware tests', () => {
123123
'FIXED_WINDOW',
124124
{ refillRate: 1, bucketSize: 10 }, // FIXME: Replace with valid params
125125
schema,
126-
{ url: '' }
126+
{ path: '' }
127127
)
128128
).not.toThrow();
129129
});
@@ -134,7 +134,7 @@ xdescribe('Express Middleware tests', () => {
134134
'SLIDING_WINDOW_LOG',
135135
{ refillRate: 1, bucketSize: 10 }, // FIXME: Replace with valid params
136136
schema,
137-
{ url: '' }
137+
{ path: '' }
138138
)
139139
).not.toThrow();
140140
});
@@ -145,7 +145,7 @@ xdescribe('Express Middleware tests', () => {
145145
'SLIDING_WINDOW_COUNTER',
146146
{ refillRate: 1, bucketSize: 10 }, // FIXME: Replace with valid params
147147
schema,
148-
{ url: '' }
148+
{ path: '' }
149149
)
150150
).not.toThrow();
151151
});
@@ -155,7 +155,7 @@ xdescribe('Express Middleware tests', () => {
155155
const invalidSchema: GraphQLSchema = buildSchema(`{Query {name}`);
156156

157157
expect(
158-
expressRateLimitMiddleware('TOKEN_BUCKET', {}, invalidSchema, { url: '' })
158+
expressRateLimitMiddleware('TOKEN_BUCKET', {}, invalidSchema, { path: '' })
159159
).toThrowError('ValidationError');
160160
});
161161

@@ -165,7 +165,7 @@ xdescribe('Express Middleware tests', () => {
165165
'TOKEN_BUCKET',
166166
{ bucketSize: 10, refillRate: 1 },
167167
schema,
168-
{ socket: { host: 'localhost', port: 1 } }
168+
{ host: 'localhost', port: 1 }
169169
)
170170
).toThrow('ECONNREFUSED');
171171
});

0 commit comments

Comments
 (0)