forked from redis/node-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
66 lines (59 loc) · 1.83 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
import {
RedisModules,
RedisScripts,
createClient as _createClient,
RedisClientOptions,
RedisClientType as _RedisClientType,
createCluster as _createCluster,
RedisClusterOptions,
RedisClusterType as _RedisClusterType
} from '@node-redis/client';
import RedisBloomModules from '@node-redis/bloom';
import RedisGraph from '@node-redis/graph';
import RedisJSON from '@node-redis/json';
import RediSearch from '@node-redis/search';
import RedisTimeSeries from '@node-redis/time-series';
export * from '@node-redis/client';
export * from '@node-redis/bloom';
export * from '@node-redis/graph';
export * from '@node-redis/json';
export * from '@node-redis/search';
export * from '@node-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,
S extends RedisScripts = Record<string, never>
> = _RedisClientType<M, S>;
export function createClient<M extends RedisModules, S extends RedisScripts>(
options?: RedisClientOptions<M, S>
): _RedisClientType<RedisDefaultModules & M, S> {
return _createClient({
...options,
modules: {
...modules,
...(options?.modules as M)
}
});
}
export type RedisClusterType<
M extends RedisModules = RedisDefaultModules,
S extends RedisScripts = Record<string, never>
> = _RedisClusterType<M, S>;
export function createCluster<M extends RedisModules, S extends RedisScripts>(
options: RedisClusterOptions<M, S>
): RedisClusterType<RedisDefaultModules & M, S> {
return _createCluster({
...options,
modules: {
...modules,
...(options?.modules as M)
}
});
}