update status-page backend

This commit is contained in:
Alex Holliday committed 2025-02-03 15:06:25 -08:00
1 parent 27ec0eabb2
commit d853c50840
5 files changed
+68 -24

No files matched your search

+16 -5
View File
@@ -23,11 +23,6 @@ const StatusPageSchema = mongoose.Schema(
required: true,
default: "#4169E1",
},
theme: {
type: String,
required: true,
default: "light",
},
monitors: [
{
type: mongoose.Schema.Types.ObjectId,
@@ -35,6 +30,22 @@ const StatusPageSchema = mongoose.Schema(
required: true,
},
],
logo: {
data: Buffer,
contentType: String,
},
isPublished: {
type: Boolean,
default: false,
},
showCharts: {
type: Boolean,
default: true,
},
showUptimePercentage: {
type: Boolean,
default: true,
},
},
{ timestamps: true }
);
+10 -4
View File
@@ -3,9 +3,15 @@ import { errorMessages } from "../../../utils/messages.js";
const SERVICE_NAME = "statusPageModule";
const createStatusPage = async (statusPageData) => {
const createStatusPage = async (statusPageData, image) => {
try {
const statusPage = new StatusPage({ ...statusPageData });
if (image) {
statusPage.logo = {
data: image.buffer,
contentType: image.mimetype,
};
}
await statusPage.save();
return statusPage;
} catch (error) {
@@ -20,9 +26,9 @@ const createStatusPage = async (statusPageData) => {
}
};
const getStatusPageByUrl = async (url) => {
const getStatusPage = async () => {
try {
const statusPage = await StatusPage.findOne({ url });
const statusPage = await StatusPage.findOne();
if (statusPage === null || statusPage === undefined) {
const error = new Error(errorMessages.STATUS_PAGE_NOT_FOUND);
error.status = 404;
@@ -37,4 +43,4 @@ const getStatusPageByUrl = async (url) => {
}
};
export { createStatusPage, getStatusPageByUrl };
export { createStatusPage, getStatusPage };