|
1 | 1 | import { FastifyPluginCallback } from 'fastify';
|
2 | 2 | import { Cluster, Redis, RedisOptions } from 'ioredis';
|
3 | 3 |
|
4 |
| -export interface FastifyRedisNamespacedInstance { |
5 |
| - [namespace: string]: Redis; |
6 |
| -} |
7 |
| - |
8 |
| -export type FastifyRedis = FastifyRedisNamespacedInstance & Redis; |
| 4 | +type FastifyRedisPluginType = FastifyPluginCallback<fastifyRedis.FastifyRedisPluginOptions> |
9 | 5 |
|
10 | 6 | declare module 'fastify' {
|
11 | 7 | interface FastifyInstance {
|
12 |
| - redis: FastifyRedis; |
| 8 | + redis: fastifyRedis.FastifyRedis; |
13 | 9 | }
|
14 | 10 | }
|
15 | 11 |
|
16 |
| -export type FastifyRedisPluginOptions = (RedisOptions & |
17 |
| -{ |
18 |
| - url?: string; |
19 |
| - namespace?: string; |
20 |
| -}) | { |
21 |
| - client: Redis | Cluster; |
22 |
| - namespace?: string; |
23 |
| - closeClient?: boolean; |
24 |
| -} |
| 12 | +declare namespace fastifyRedis { |
25 | 13 |
|
26 |
| -/** |
27 |
| - * @deprecated Use `FastifyRedisPluginOptions` instead |
28 |
| - */ |
29 |
| -export type FastifyRedisPlugin = FastifyRedisPluginOptions; |
| 14 | + export interface FastifyRedisNamespacedInstance { |
| 15 | + [namespace: string]: Redis; |
| 16 | + } |
| 17 | + |
| 18 | + export type FastifyRedis = FastifyRedisNamespacedInstance & Redis; |
| 19 | + |
| 20 | + export type FastifyRedisPluginOptions = (RedisOptions & |
| 21 | + { |
| 22 | + url?: string; |
| 23 | + namespace?: string; |
| 24 | + }) | { |
| 25 | + client: Redis | Cluster; |
| 26 | + namespace?: string; |
| 27 | + closeClient?: boolean; |
| 28 | + } |
| 29 | + /* |
| 30 | + * @deprecated Use `FastifyRedisPluginOptions` instead |
| 31 | + */ |
| 32 | + export type FastifyRedisPlugin = FastifyRedisPluginOptions; |
| 33 | + export const fastifyRedis: FastifyRedisPluginType |
| 34 | + export { fastifyRedis as default } |
| 35 | +} |
30 | 36 |
|
31 |
| -declare const fastifyRedis: FastifyPluginCallback<FastifyRedisPluginOptions>; |
32 |
| -export default fastifyRedis; |
| 37 | +declare function fastifyRedis(...params: Parameters<FastifyRedisPluginType>): ReturnType<FastifyRedisPluginType> |
| 38 | +export = fastifyRedis |
0 commit comments