Skip to content

Commit 423e2b1

Browse files
authored
fix: 🐛 allow Redis.Cluster signature for client (#163)
🏁 Closes: #162
1 parent 47eeb8f commit 423e2b1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FastifyPluginCallback } from 'fastify';
2-
import { Redis, RedisOptions } from 'ioredis';
2+
import { Cluster, Redis, RedisOptions } from 'ioredis';
33

44
export interface FastifyRedisNamespacedInstance {
55
[namespace: string]: Redis;
@@ -18,7 +18,7 @@ export type FastifyRedisPluginOptions = (RedisOptions &
1818
url?: string;
1919
namespace?: string;
2020
}) | {
21-
client: Redis;
21+
client: Redis | Cluster;
2222
namespace?: string;
2323
closeClient?: boolean;
2424
}

types/index.test-d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import Fastify, { FastifyInstance } from 'fastify'
22
import IORedis, { Redis } from 'ioredis'
33
import { expectAssignable, expectError, expectType } from 'tsd'
4-
import fastifyRedis, { FastifyRedis, FastifyRedisNamespacedInstance } from '..'
4+
import fastifyRedis, { FastifyRedis, FastifyRedisNamespacedInstance, FastifyRedisPluginOptions } from '..'
55

66
const app: FastifyInstance = Fastify()
77
const redis: Redis = new IORedis({ host: 'localhost', port: 6379 })
8+
const redisCluster= new IORedis.Cluster([{ host: 'localhost', port: 6379 }])
89

910
app.register(fastifyRedis, { host: '127.0.0.1' })
1011

@@ -19,6 +20,10 @@ app.register(fastifyRedis, {
1920
url: 'redis://127.0.0.1:6379'
2021
})
2122

23+
expectAssignable<FastifyRedisPluginOptions>({
24+
client: redisCluster
25+
})
26+
2227
expectError(app.register(fastifyRedis, {
2328
namespace: 'three',
2429
unknownOption: 'this should trigger a typescript error'

0 commit comments

Comments
 (0)