@vasrefil/api-toolkit 1.7.4 → 1.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import IORedis from 'ioredis';
|
|
2
2
|
export declare enum JOB {
|
|
3
3
|
EMAIL = "EMAIL",
|
|
4
4
|
IN_APP_NOTIFICATION = "IN_APP_NOTIFICATION"
|
|
5
5
|
}
|
|
6
|
+
declare class BullmqClient_ {
|
|
7
|
+
private connection;
|
|
8
|
+
init: () => void;
|
|
9
|
+
getConnection(): IORedis;
|
|
10
|
+
}
|
|
11
|
+
export declare const BullmqClient: BullmqClient_;
|
|
12
|
+
export {};
|
|
@@ -3,12 +3,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
6
|
+
exports.BullmqClient = exports.JOB = void 0;
|
|
7
|
+
const ioredis_1 = __importDefault(require("ioredis"));
|
|
8
8
|
const env_1 = __importDefault(require("../env"));
|
|
9
|
-
exports.connection = new IORedis(env_1.default.BULLMQ_REDIS_URL, { maxRetriesPerRequest: null });
|
|
10
9
|
var JOB;
|
|
11
10
|
(function (JOB) {
|
|
12
11
|
JOB["EMAIL"] = "EMAIL";
|
|
13
12
|
JOB["IN_APP_NOTIFICATION"] = "IN_APP_NOTIFICATION";
|
|
14
13
|
})(JOB || (exports.JOB = JOB = {}));
|
|
14
|
+
class BullmqClient_ {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.init = () => {
|
|
17
|
+
try {
|
|
18
|
+
this.connection = new ioredis_1.default(env_1.default.BULLMQ_REDIS_URL, { maxRetriesPerRequest: null });
|
|
19
|
+
this.connection.on('error', (err) => console.log('BullmqRedis-error', err));
|
|
20
|
+
this.connection.on('connect', () => console.log('BullmqRedis server connected...'));
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.log(error);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
getConnection() {
|
|
28
|
+
return this.connection;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.BullmqClient = new BullmqClient_;
|
|
@@ -8,6 +8,7 @@ const bullmq_1 = require("bullmq");
|
|
|
8
8
|
const common_1 = require("./common");
|
|
9
9
|
const common_2 = require("./common");
|
|
10
10
|
const env_1 = __importDefault(require("../env"));
|
|
11
|
+
const connection = common_1.BullmqClient.getConnection();
|
|
11
12
|
const attempts = env_1.default.NODE_ENV === env_1.default.NODE_ENVS.PROD ? 10 : 1;
|
|
12
13
|
const removeOnComplete = {
|
|
13
14
|
age: (3600 * 24) * 3, // 3 days
|
|
@@ -17,7 +18,7 @@ const backoff = {
|
|
|
17
18
|
delay: 10000,
|
|
18
19
|
};
|
|
19
20
|
exports.EmailQueue = new bullmq_1.Queue(common_2.JOB.EMAIL, {
|
|
20
|
-
connection
|
|
21
|
+
connection,
|
|
21
22
|
defaultJobOptions: {
|
|
22
23
|
attempts,
|
|
23
24
|
backoff,
|
|
@@ -25,7 +26,7 @@ exports.EmailQueue = new bullmq_1.Queue(common_2.JOB.EMAIL, {
|
|
|
25
26
|
},
|
|
26
27
|
});
|
|
27
28
|
exports.InAppNotificationQueue = new bullmq_1.Queue(common_2.JOB.IN_APP_NOTIFICATION, {
|
|
28
|
-
connection
|
|
29
|
+
connection,
|
|
29
30
|
defaultJobOptions: {
|
|
30
31
|
attempts: 1,
|
|
31
32
|
backoff,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmailUtil = void 0;
|
|
4
|
-
const queue_1 = require("
|
|
5
|
-
const helpers_1 = require("
|
|
4
|
+
const queue_1 = require("./../background-jobs/queue");
|
|
5
|
+
const helpers_1 = require("../helpers");
|
|
6
6
|
class EmailUtil_ {
|
|
7
7
|
constructor() {
|
|
8
8
|
this.send_email = async (payload) => {
|