add route, controller, and db method for getting all status pages by ID

This commit is contained in:
Alex Holliday committed 2025-02-10 13:41:21 -08:00
1 parent f78343d03f
commit 48cfeb1558
6 files changed
+64 -9

No files matched your search

+16 -1
View File
@@ -2,6 +2,7 @@ import { handleError, handleValidationError } from "./controllerUtils.js";
import {
createStatusPageBodyValidation,
getStatusPageParamValidation,
getStatusPageQueryValidation,
imageValidation,
} from "../validation/joi.js";
import { successMessages, errorMessages } from "../utils/messages.js";
@@ -73,13 +74,14 @@ class StatusPageController {
getStatusPageByUrl = async (req, res, next) => {
try {
await getStatusPageParamValidation.validateAsync(req.params);
await getStatusPageQueryValidation.validateAsync(req.query);
} catch (error) {
next(handleValidationError(error, SERVICE_NAME));
return;
}
try {
const statusPage = await this.db.getStatusPageByUrl(req.params.url);
const statusPage = await this.db.getStatusPageByUrl(req.params.url, req.query.type);
return res.success({
msg: successMessages.STATUS_PAGE_BY_URL,
data: statusPage,
@@ -89,6 +91,19 @@ class StatusPageController {
}
};
getStatusPagesByTeamId = async (req, res, next) => {
try {
const teamId = req.params.teamId;
const statusPages = await this.db.getStatusPagesByTeamId(teamId);
return res.success({
msg: successMessages.STATUS_PAGE_BY_TEAM_ID,
data: statusPages,
});
} catch (error) {
next(handleError(error, SERVICE_NAME, "getStatusPageByUrl"));
}
};
deleteStatusPage = async (req, res, next) => {
try {
await this.db.deleteStatusPage(req.params.url);