Skip to content

Commit 3ca1567

Browse files
Boris Dorofeevnodkz
Boris Dorofeev
authored andcommitted
fix: example app
relates: #72
1 parent b9dcbee commit 3ca1567

File tree

4 files changed

+145
-354
lines changed

4 files changed

+145
-354
lines changed

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"apollo-server": "2.14.3"
88
},
99
"devDependencies": {
10-
"ts-node-dev": "^1.0.0-pre.44"
10+
"ts-node-dev": "1.1.8"
1111
},
1212
"resolutions": {
1313
"graphql": "link:../node_modules/graphql"

example/src/connectRedis.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Redis, { RedisOptions } from 'ioredis';
33
// TODO: remove get from OPTIONS
44
const BULL_REDIS_URI = process.env.BULL_REDIS_URI || 'redis://127.0.0.1:6379';
55

6-
const redisInstances = new Map<string, Redis.Redis>();
6+
const redisInstances = new Map<string, Redis>();
77

88
export function createBullConnection(type: 'queue' | 'worker' | 'scheduler' | 'events' | 'custom') {
99
const existedClient = redisInstances.get(type);
@@ -33,9 +33,10 @@ export function createBullConnection(type: 'queue' | 'worker' | 'scheduler' | 'e
3333
* rediss://localhost/0
3434
* redis-sentinel://:pass@localhost:26379,otherhost:26479/0?name=mymaster
3535
*/
36-
export function connectRedis(uri: string, opts?: RedisOptions): Redis.Redis {
36+
export function connectRedis(uri: string, opts?: RedisOptions): Redis {
3737
// TODO: UnhandledPromiseRejectionWarning: MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details.
3838
let cfg = {
39+
maxRetriesPerRequest: null,
3940
retryStrategy: (times: number) => Math.min(times * 500, 10000),
4041
reconnectOnError: (err: Error) => {
4142
const targetError = 'READONLY';
@@ -170,12 +171,12 @@ export function connectionStringSerialize(connectionStringObject: ConnectionStri
170171
export function connectionStringParse(uri: string): ConnectionStringParameters {
171172
const connectionStringParser = new RegExp(
172173
'^\\s*' + // Optional whitespace padding at the beginning of the line
173-
'([^:]+):\\/\\/' + // Scheme (Group 1)
174-
'(?:([^:@,/?=&]*)' + // User (Group 2)
175-
'(?::([^:@,/?=&]*))?@)?' + // Password (Group 3)
176-
'([^@/?=&]+)' + // Host address(es) (Group 4)
177-
'(?:\\/([^:@,?=&]+)?)?' + // Endpoint (Group 5)
178-
'(?:\\?([^:@,/?]+)?)?' + // Options (Group 6)
174+
'([^:]+):\\/\\/' + // Scheme (Group 1)
175+
'(?:([^:@,/?=&]*)' + // User (Group 2)
176+
'(?::([^:@,/?=&]*))?@)?' + // Password (Group 3)
177+
'([^@/?=&]+)' + // Host address(es) (Group 4)
178+
'(?:\\/([^:@,?=&]+)?)?' + // Endpoint (Group 5)
179+
'(?:\\?([^:@,/?]+)?)?' + // Options (Group 6)
179180
'\\s*$', // Optional whitespace padding at the end of the line
180181
'gi'
181182
);
@@ -222,9 +223,11 @@ function _parseAddress(addresses: string): ConnectionStringHost[] {
222223
return addresses.split(',').map((address) => {
223224
const i = address.indexOf(':');
224225

225-
return (i >= 0
226-
? { host: decodeURIComponent(address.substring(0, i)), port: +address.substring(i + 1) }
227-
: { host: decodeURIComponent(address) }) as ConnectionStringHost;
226+
return (
227+
i >= 0
228+
? { host: decodeURIComponent(address.substring(0, i)), port: +address.substring(i + 1) }
229+
: { host: decodeURIComponent(address) }
230+
) as ConnectionStringHost;
228231
});
229232
}
230233

0 commit comments

Comments
 (0)