add update settings method, remove all env var references possible
This commit is contained in:
1 parent
992bf099fa
commit
11b97ab3b4
17 files changed
+149
-36
No files matched your search
@@ -13,7 +13,8 @@ class EmailService {
|
||||
/**
|
||||
* Constructs an instance of the EmailService, initializing template loaders and the email transporter.
|
||||
*/
|
||||
constructor() {
|
||||
constructor(settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
/**
|
||||
* Loads an email template from the filesystem.
|
||||
*
|
||||
@@ -54,15 +55,26 @@ class EmailService {
|
||||
* The email transporter used to send emails.
|
||||
* @type {Object}
|
||||
*/
|
||||
this.transporter = nodemailer.createTransport({
|
||||
host: process.env.SYSTEM_EMAIL_HOST,
|
||||
port: process.env.SYSTEM_EMAIL_PORT,
|
||||
secure: true, // Use `true` for port 465, `false` for all other ports
|
||||
|
||||
const {
|
||||
systemEmailHost,
|
||||
systemEmailPort,
|
||||
systemEmailAddress,
|
||||
systemEmailPassword,
|
||||
} = this.settingsService.getSettings();
|
||||
|
||||
const emailConfig = {
|
||||
host: systemEmailHost,
|
||||
port: systemEmailPort,
|
||||
secure: true,
|
||||
auth: {
|
||||
user: process.env.SYSTEM_EMAIL_ADDRESS,
|
||||
pass: process.env.SYSTEM_EMAIL_PASSWORD,
|
||||
user: systemEmailAddress,
|
||||
pass: systemEmailPassword,
|
||||
},
|
||||
});
|
||||
};
|
||||
console.log(emailConfig);
|
||||
|
||||
this.transporter = nodemailer.createTransport(emailConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
const { Queue, Worker, Job } = require("bullmq");
|
||||
const QUEUE_NAME = "monitors";
|
||||
const connection = {
|
||||
host: process.env.REDIS_HOST || "127.0.0.1",
|
||||
port: process.env.REDIS_PORT || 6379,
|
||||
};
|
||||
|
||||
const JOBS_PER_WORKER = 5;
|
||||
const logger = require("../utils/logger");
|
||||
const { errorMessages, successMessages } = require("../utils/messages");
|
||||
@@ -15,13 +12,20 @@ class JobQueue {
|
||||
* @constructor
|
||||
* @throws {Error}
|
||||
*/
|
||||
constructor(networkService) {
|
||||
constructor(settingsService) {
|
||||
const { redisHost, redisPort } = settingsService.getSettings();
|
||||
const connection = {
|
||||
host: redisHost || "127.0.0.1",
|
||||
port: redisPort || 6379,
|
||||
};
|
||||
this.connection = connection;
|
||||
this.queue = new Queue(QUEUE_NAME, {
|
||||
connection,
|
||||
});
|
||||
this.workers = [];
|
||||
this.db = null;
|
||||
this.networkService = null;
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,8 +35,8 @@ class JobQueue {
|
||||
* @returns {Promise<JobQueue>} - Returns a new JobQueue
|
||||
*
|
||||
*/
|
||||
static async createJobQueue(db, networkService) {
|
||||
const queue = new JobQueue();
|
||||
static async createJobQueue(db, networkService, settingsService) {
|
||||
const queue = new JobQueue(settingsService);
|
||||
try {
|
||||
queue.db = db;
|
||||
queue.networkService = networkService;
|
||||
@@ -99,7 +103,7 @@ class JobQueue {
|
||||
}
|
||||
},
|
||||
{
|
||||
connection,
|
||||
connection: this.connection,
|
||||
}
|
||||
);
|
||||
return worker;
|
||||
|
||||
Reference in new issue
Block a user