forked from redis/node-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
77 lines (70 loc) · 1.99 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import {
RedisModules,
RedisFunctions,
RedisScripts,
createClient as _createClient,
RedisClientOptions,
RedisClientType as _RedisClientType,
createCluster as _createCluster,
RedisClusterOptions,
RedisClusterType as _RedisClusterType
} from '@redis/client';
import RedisBloomModules from '@redis/bloom';
import RedisGraph from '@redis/graph';
import RedisJSON from '@redis/json';
import RediSearch from '@redis/search';
import RedisTimeSeries from '@redis/time-series';
export * from '@redis/client';
export * from '@redis/bloom';
export * from '@redis/graph';
export * from '@redis/json';
export * from '@redis/search';
export * from '@redis/time-series';
const modules = {
...RedisBloomModules,
graph: RedisGraph,
json: RedisJSON,
ft: RediSearch,
ts: RedisTimeSeries
};
export type RedisDefaultModules = typeof modules;
export type RedisClientType<
M extends RedisModules = RedisDefaultModules,
F extends RedisFunctions = Record<string, never>,
S extends RedisScripts = Record<string, never>
> = _RedisClientType<M, F, S>;
export function createClient<
M extends RedisModules,
F extends RedisFunctions,
S extends RedisScripts
>(
options?: RedisClientOptions<M, F, S>
): _RedisClientType<RedisDefaultModules & M, F, S> {
return _createClient({
...options,
modules: {
...modules,
...(options?.modules as M)
}
});
}
export type RedisClusterType<
M extends RedisModules = RedisDefaultModules,
F extends RedisFunctions = Record<string, never>,
S extends RedisScripts = Record<string, never>
> = _RedisClusterType<M, F, S>;
export function createCluster<
M extends RedisModules,
F extends RedisFunctions,
S extends RedisScripts
>(
options: RedisClusterOptions<M, F, S>
): RedisClusterType<RedisDefaultModules & M, F, S> {
return _createCluster({
...options,
modules: {
...modules,
...(options?.modules as M)
}
});
}