fix: i18n rebase

This commit is contained in:
cihatata
2025-02-06 23:38:13 +03:00
committed by cihat
parent 7b6eed96f4
commit 4c92922d40
5 changed files with 26 additions and 10 deletions

View File

@@ -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"));

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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"
}

View File

@@ -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');
}