add route, controller and DB methods for updating status page

This commit is contained in:
Alex Holliday committed 2025-02-05 10:55:08 -08:00
1 parent ff47af95fa
commit 76b21f1d8c
4 files changed
+60 -2

No files matched your search

+33 -2
View File
@@ -27,6 +27,26 @@ const createStatusPage = async (statusPageData, image) => {
}
};
const updateStatusPage = async (statusPageData, image) => {
try {
if (image) {
statusPageData.logo = {
data: image.buffer,
contentType: image.mimetype,
};
}
const statusPage = await StatusPage.findOneAndUpdate({}, statusPageData, {
new: true,
});
return statusPage;
} catch (error) {
error.service = SERVICE_NAME;
error.method = "updateStatusPage";
throw error;
}
};
const getStatusPage = async () => {
try {
const statusPageQuery = await StatusPage.aggregate([
@@ -79,7 +99,18 @@ const getStatusPage = async () => {
},
{
$project: {
statusPage: 1,
statusPage: {
_id: 1,
color: 1,
companyName: 1,
isPublished: 1,
logo: 1,
originalMonitors: 1,
showCharts: 1,
showUptimePercentage: 1,
timezone: 1,
url: 1,
},
monitors: {
$sortArray: {
input: "$monitors",
@@ -122,4 +153,4 @@ const deleteStatusPage = async () => {
}
};
export { createStatusPage, getStatusPage, deleteStatusPage };
export { createStatusPage, updateStatusPage, getStatusPage, deleteStatusPage };