From 4c92922d40172b82ebf70e2d21bea48f3cb50fac Mon Sep 17 00:00:00 2001 From: cihatata Date: Thu, 6 Feb 2025 23:38:13 +0300 Subject: [PATCH] fix: i18n rebase --- Server/controllers/statusPageController.js | 7 +++---- Server/db/mongo/modules/monitorModule.js | 3 +-- Server/db/mongo/modules/statusPageModule.js | 13 ++++++++++--- Server/locales/en.json | 4 +++- Server/service/stringService.js | 9 +++++++++ 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Server/controllers/statusPageController.js b/Server/controllers/statusPageController.js index 6c1192b95..00b8d538d 100644 --- a/Server/controllers/statusPageController.js +++ b/Server/controllers/statusPageController.js @@ -5,7 +5,6 @@ import { getStatusPageQueryValidation, imageValidation, } from "../validation/joi.js"; -import { successMessages, errorMessages } from "../utils/messages.js"; const SERVICE_NAME = "statusPageController"; @@ -47,12 +46,12 @@ class StatusPageController { try { const statusPage = await this.db.updateStatusPage(req.body, req.file); if (statusPage === null) { - const error = new Error(errorMessages.STATUS_PAGE_NOT_FOUND); + const error = new Error(this.stringService.statusPageNotFound); error.status = 404; throw error; } return res.success({ - msg: successMessages.STATUS_PAGE_UPDATE, + msg: this.stringService.statusPageUpdate, data: statusPage, }); } catch (error) { @@ -109,7 +108,7 @@ class StatusPageController { try { await this.db.deleteStatusPage(req.params.url); return res.success({ - msg: successMessages.STATUS_PAGE_DELETE, + msg: this.stringService.statusPageDelete, }); } catch (error) { next(handleError(error, SERVICE_NAME, "deleteStatusPage")); diff --git a/Server/db/mongo/modules/monitorModule.js b/Server/db/mongo/modules/monitorModule.js index e217bc9e1..e1db09f0a 100644 --- a/Server/db/mongo/modules/monitorModule.js +++ b/Server/db/mongo/modules/monitorModule.js @@ -3,7 +3,6 @@ import Check from "../../models/Check.js"; import PageSpeedCheck from "../../models/PageSpeedCheck.js"; import HardwareCheck from "../../models/HardwareCheck.js"; import DistributedUptimeCheck from "../../models/DistributedUptimeCheck.js"; -import { errorMessages } from "../../../utils/messages.js"; import Notification from "../../models/Notification.js"; import { NormalizeData, NormalizeDataUptimeDetails } from "../../../utils/dataUtils.js"; import ServiceRegistry from "../../../service/serviceRegistry.js"; @@ -376,7 +375,7 @@ const getDistributedUptimeDetailsById = async (req) => { const { monitorId } = req.params; const monitor = await Monitor.findById(monitorId); if (monitor === null || monitor === undefined) { - throw new Error(errorMessages.DB_FIND_MONITOR_BY_ID(monitorId)); + throw new Error(this.stringService.dbFindMonitorById(monitorId)); } const { dateRange, normalize } = req.query; diff --git a/Server/db/mongo/modules/statusPageModule.js b/Server/db/mongo/modules/statusPageModule.js index bd2b47375..23cfe3f4d 100644 --- a/Server/db/mongo/modules/statusPageModule.js +++ b/Server/db/mongo/modules/statusPageModule.js @@ -1,10 +1,13 @@ import StatusPage from "../../models/StatusPage.js"; -import { errorMessages } from "../../../utils/messages.js"; import { NormalizeData } from "../../../utils/dataUtils.js"; +import ServiceRegistry from "../../../service/serviceRegistry.js"; +import StringService from "../../../service/stringService.js"; const SERVICE_NAME = "statusPageModule"; const createStatusPage = async (statusPageData, image) => { + const stringService = ServiceRegistry.get(StringService.SERVICE_NAME); + try { const statusPage = new StatusPage({ ...statusPageData }); if (image) { @@ -67,10 +70,12 @@ const getStatusPageByUrl = async (url, type) => { }; const getStatusPagesByTeamId = async (teamId) => { + const stringService = ServiceRegistry.get(StringService.SERVICE_NAME); + try { const statusPages = await StatusPage.find({ teamId }); if (statusPages.length === 0) { - const error = new Error(errorMessages.STATUS_PAGE_NOT_FOUND); + const error = new Error(stringService.statusPageNotFound); error.status = 404; throw error; } @@ -83,6 +88,8 @@ const getStatusPagesByTeamId = async (teamId) => { }; const getStatusPage = async (url) => { + const stringService = ServiceRegistry.get(StringService.SERVICE_NAME); + try { const statusPageQuery = await StatusPage.aggregate([ { $match: { url: url } }, @@ -156,7 +163,7 @@ const getStatusPage = async (url) => { }, ]); if (!statusPageQuery.length) { - const error = new Error(errorMessages.STATUS_PAGE_NOT_FOUND); + const error = new Error(stringService.statusPageNotFound); error.status = 404; throw error; } diff --git a/Server/locales/en.json b/Server/locales/en.json index a438e5fc8..c67ca0a7b 100644 --- a/Server/locales/en.json +++ b/Server/locales/en.json @@ -141,5 +141,7 @@ "dockerSuccess": "Docker container status fetched successfully", "portSuccess": "Port connected successfully", "monitorPause": "Monitor paused successfully", - "monitorResume": "Monitor resumed successfully" + "monitorResume": "Monitor resumed successfully", + "statusPageDelete": "Status page deleted successfully", + "statusPageUpdate": "Status page updated successfully" } \ No newline at end of file diff --git a/Server/service/stringService.js b/Server/service/stringService.js index 3c95dacd9..cf679e85a 100644 --- a/Server/service/stringService.js +++ b/Server/service/stringService.js @@ -241,6 +241,15 @@ class StringService { return this.translationService.getTranslation('statusPageCreate'); } + get statusPageDelete() { + return this.translationService.getTranslation('statusPageDelete'); + } + + get statusPageUpdate() { + return this.translationService.getTranslation('statusPageUpdate'); + } + + get statusPageNotFound() { return this.translationService.getTranslation('statusPageNotFound'); }