fix: constructure

This commit is contained in:
cihat
2025-01-30 08:37:42 +03:00
parent d0e09fe77f
commit c6b3932677
9 changed files with 33 additions and 37 deletions

View File

@@ -13,16 +13,14 @@ import { getTokenFromHeaders, tokenType } from "../utils/utils.js";
import crypto from "crypto";
import { handleValidationError, handleError } from "./controllerUtils.js";
const SERVICE_NAME = "authController";
import ServiceRegistry from "../service/serviceRegistry.js";
import StringService from "../service/stringService.js";
class AuthController {
constructor(db, settingsService, emailService, jobQueue) {
constructor(db, settingsService, emailService, jobQueue, stringService) {
this.db = db;
this.settingsService = settingsService;
this.emailService = emailService;
this.jobQueue = jobQueue;
this.stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
this.stringService = stringService;
}
/**

View File

@@ -12,16 +12,14 @@ import {
import jwt from "jsonwebtoken";
import { getTokenFromHeaders } from "../utils/utils.js";
import { handleValidationError, handleError } from "./controllerUtils.js";
import ServiceRegistry from "../service/serviceRegistry.js";
import StringService from "../service/stringService.js";
const SERVICE_NAME = "checkController";
class CheckController {
constructor(db, settingsService) {
constructor(db, settingsService, stringService) {
this.db = db;
this.settingsService = settingsService;
this.stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
this.stringService = stringService;
}
createCheck = async (req, res, next) => {

View File

@@ -7,17 +7,15 @@ import logger from "../utils/logger.js";
import jwt from "jsonwebtoken";
import { handleError, handleValidationError } from "./controllerUtils.js";
import { getTokenFromHeaders } from "../utils/utils.js";
import ServiceRegistry from "../service/serviceRegistry.js";
import StringService from "../service/stringService.js";
const SERVICE_NAME = "inviteController";
class InviteController {
constructor(db, settingsService, emailService) {
constructor(db, settingsService, emailService, stringService) {
this.db = db;
this.settingsService = settingsService;
this.emailService = emailService;
this.stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
this.stringService = stringService;
}
/**

View File

@@ -10,16 +10,14 @@ import {
import jwt from "jsonwebtoken";
import { getTokenFromHeaders } from "../utils/utils.js";
import { handleValidationError, handleError } from "./controllerUtils.js";
import ServiceRegistry from "../service/serviceRegistry.js";
import StringService from "../service/stringService.js";
const SERVICE_NAME = "maintenanceWindowController";
class MaintenanceWindowController {
constructor(db, settingsService) {
constructor(db, settingsService, stringService) {
this.db = db;
this.settingsService = settingsService;
this.stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
this.stringService = stringService;
}
createMaintenanceWindows = async (req, res, next) => {

View File

@@ -20,16 +20,14 @@ import logger from "../utils/logger.js";
import { handleError, handleValidationError } from "./controllerUtils.js";
import axios from "axios";
import seedDb from "../db/mongo/utils/seedDb.js";
import ServiceRegistry from "../service/serviceRegistry.js";
import StringService from "../service/stringService.js";
const SERVICE_NAME = "monitorController";
class MonitorController {
constructor(db, settingsService, jobQueue) {
constructor(db, settingsService, jobQueue, stringService) {
this.db = db;
this.settingsService = settingsService;
this.jobQueue = jobQueue;
this.stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
this.stringService = stringService;
}
/**

View File

@@ -1,13 +1,11 @@
import { handleError } from "./controllerUtils.js";
import ServiceRegistry from "../service/serviceRegistry.js";
import StringService from "../service/stringService.js";
const SERVICE_NAME = "JobQueueController";
class JobQueueController {
constructor(jobQueue) {
constructor(jobQueue, stringService) {
this.jobQueue = jobQueue;
this.stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
this.stringService = stringService;
}
getMetrics = async (req, res, next) => {

View File

@@ -1,15 +1,13 @@
import ServiceRegistry from "../service/serviceRegistry.js";
import StringService from "../service/stringService.js";
import { updateAppSettingsBodyValidation } from "../validation/joi.js";
import { handleValidationError, handleError } from "./controllerUtils.js";
const SERVICE_NAME = "SettingsController";
class SettingsController {
constructor(db, settingsService) {
constructor(db, settingsService, stringService) {
this.db = db;
this.settingsService = settingsService;
this.stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
this.stringService = stringService;
}
getAppSettings = async (req, res, next) => {

View File

@@ -10,9 +10,9 @@ import { successMessages, errorMessages } from "../utils/messages.js";
const SERVICE_NAME = "statusPageController";
class StatusPageController {
constructor(db) {
constructor(db, stringService) {
this.db = db;
this.stringService = ServiceRegistry.get(StringService.SERVICE_NAME);
this.stringService = stringService;
}
createStatusPage = async (req, res, next) => {

View File

@@ -222,39 +222,49 @@ const startApp = async () => {
ServiceRegistry.get(SettingsService.SERVICE_NAME),
ServiceRegistry.get(EmailService.SERVICE_NAME),
ServiceRegistry.get(JobQueue.SERVICE_NAME),
ServiceRegistry.get(StringService.SERVICE_NAME)
);
const monitorController = new MonitorController(
ServiceRegistry.get(MongoDB.SERVICE_NAME),
ServiceRegistry.get(SettingsService.SERVICE_NAME),
ServiceRegistry.get(JobQueue.SERVICE_NAME)
ServiceRegistry.get(JobQueue.SERVICE_NAME),
ServiceRegistry.get(StringService.SERVICE_NAME)
);
const settingsController = new SettingsController(
ServiceRegistry.get(MongoDB.SERVICE_NAME),
ServiceRegistry.get(SettingsService.SERVICE_NAME)
ServiceRegistry.get(SettingsService.SERVICE_NAME),
ServiceRegistry.get(StringService.SERVICE_NAME)
);
const checkController = new CheckController(
ServiceRegistry.get(MongoDB.SERVICE_NAME),
ServiceRegistry.get(SettingsService.SERVICE_NAME)
ServiceRegistry.get(SettingsService.SERVICE_NAME),
ServiceRegistry.get(StringService.SERVICE_NAME)
);
const inviteController = new InviteController(
ServiceRegistry.get(MongoDB.SERVICE_NAME),
ServiceRegistry.get(SettingsService.SERVICE_NAME),
ServiceRegistry.get(EmailService.SERVICE_NAME)
ServiceRegistry.get(EmailService.SERVICE_NAME),
ServiceRegistry.get(StringService.SERVICE_NAME)
);
const maintenanceWindowController = new MaintenanceWindowController(
ServiceRegistry.get(MongoDB.SERVICE_NAME),
ServiceRegistry.get(SettingsService.SERVICE_NAME)
ServiceRegistry.get(SettingsService.SERVICE_NAME),
ServiceRegistry.get(StringService.SERVICE_NAME)
);
const queueController = new QueueController(ServiceRegistry.get(JobQueue.SERVICE_NAME));
const queueController = new QueueController(
ServiceRegistry.get(JobQueue.SERVICE_NAME),
ServiceRegistry.get(StringService.SERVICE_NAME)
);
const statusPageController = new StatusPageController(
ServiceRegistry.get(MongoDB.SERVICE_NAME)
ServiceRegistry.get(MongoDB.SERVICE_NAME),
ServiceRegistry.get(StringService.SERVICE_NAME)
);
const distributedUptimeController = new DistributedUptimeController(