@hastehaul/common 1.0.18 → 1.0.20
Sign up to get free protection for your applications and to get access to all the features.
- package/build/connections-wrappers/redis-connection-wrapper.d.ts +10 -6
- package/build/connections-wrappers/redis-connection-wrapper.js +11 -7
- package/build/index.d.ts +1 -0
- package/build/index.js +2 -0
- package/build/utils/random-codes.d.ts +1 -1
- package/build/utils/random-codes.js +3 -0
- package/package.json +1 -1
@@ -1,6 +1,7 @@
|
|
1
1
|
import IORedis from "ioredis";
|
2
2
|
/**
|
3
|
-
* A wrapper class for the Redis client
|
3
|
+
* A wrapper class for the Redis client. This class manages connections and provides
|
4
|
+
* a centralized client instance for a Redis database.
|
4
5
|
*/
|
5
6
|
export declare class RedisWrapper {
|
6
7
|
private _redisClient?;
|
@@ -14,11 +15,14 @@ export declare class RedisWrapper {
|
|
14
15
|
*/
|
15
16
|
get client(): IORedis;
|
16
17
|
/**
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
* Connect to the Redis server using the specified host and port.
|
19
|
+
*
|
20
|
+
* The client instance will be stored in the `_redisClient` property for later access.
|
21
|
+
*
|
22
|
+
* @param {string} host - The Redis server host address (default is "customer-redis-srv").
|
23
|
+
* @param {number} port - The Redis server port number (default is 6379).
|
24
|
+
*/
|
25
|
+
connect(host?: string, port?: number): void;
|
22
26
|
}
|
23
27
|
/**
|
24
28
|
* Singleton instance of the RedisWrapper class to provide a centralized Redis client connection.
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.redisWrapper = exports.RedisWrapper = void 0;
|
7
7
|
const ioredis_1 = __importDefault(require("ioredis"));
|
8
8
|
/**
|
9
|
-
* A wrapper class for the Redis client
|
9
|
+
* A wrapper class for the Redis client. This class manages connections and provides
|
10
|
+
* a centralized client instance for a Redis database.
|
10
11
|
*/
|
11
12
|
class RedisWrapper {
|
12
13
|
constructor() {
|
@@ -25,12 +26,15 @@ class RedisWrapper {
|
|
25
26
|
return this._redisClient;
|
26
27
|
}
|
27
28
|
/**
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
* Connect to the Redis server using the specified host and port.
|
30
|
+
*
|
31
|
+
* The client instance will be stored in the `_redisClient` property for later access.
|
32
|
+
*
|
33
|
+
* @param {string} host - The Redis server host address (default is "customer-redis-srv").
|
34
|
+
* @param {number} port - The Redis server port number (default is 6379).
|
35
|
+
*/
|
36
|
+
connect(host, port) {
|
37
|
+
this._redisClient = new ioredis_1.default({ host: host || this.host, port: port || this.port, maxRetriesPerRequest: null });
|
34
38
|
this._redisClient.on("connect", function () {
|
35
39
|
console.info("Redis Server Connected!");
|
36
40
|
});
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
@@ -113,6 +113,8 @@ __exportStar(require("./utils/enums"), exports);
|
|
113
113
|
__exportStar(require("./utils/read-dir"), exports);
|
114
114
|
//TODO: DOCUMENT
|
115
115
|
__exportStar(require("./utils/schemas"), exports);
|
116
|
+
//TODO: DOCUMENT
|
117
|
+
__exportStar(require("./utils/random-codes"), exports);
|
116
118
|
/**
|
117
119
|
*? Re-exports all the contents from the "base-producers" module.
|
118
120
|
*
|
@@ -9,4 +9,4 @@
|
|
9
9
|
*
|
10
10
|
* @returns {Promise<string>} - A Promise that resolves with the generated codes as a string.
|
11
11
|
*/
|
12
|
-
declare function generateRandomCodesAsync(characters: string, numberOfCodes: number, codeSize: number, includeHyphens: boolean, chunkSize: number): Promise<string>;
|
12
|
+
export declare function generateRandomCodesAsync(characters: string, numberOfCodes: number, codeSize: number, includeHyphens: boolean, chunkSize: number): Promise<string>;
|
@@ -8,6 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.generateRandomCodesAsync = void 0;
|
11
13
|
/**
|
12
14
|
* Generates random codes as an async function using await.
|
13
15
|
*
|
@@ -50,3 +52,4 @@ function generateRandomCodesAsync(characters, numberOfCodes, codeSize, includeHy
|
|
50
52
|
return codes;
|
51
53
|
});
|
52
54
|
}
|
55
|
+
exports.generateRandomCodesAsync = generateRandomCodesAsync;
|