2024-10-15 11:57:37 +08:00
|
|
|
import mongoose from "mongoose";
|
|
|
|
|
import Notification from "./Notification.js";
|
2024-05-10 13:36:04 -07:00
|
|
|
|
2024-05-21 13:52:28 -07:00
|
|
|
const MonitorSchema = mongoose.Schema(
|
2024-10-17 12:07:30 +08:00
|
|
|
{
|
|
|
|
|
userId: {
|
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
|
ref: "User",
|
|
|
|
|
immutable: true,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
teamId: {
|
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
|
ref: "Team",
|
|
|
|
|
immutable: true,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
name: {
|
|
|
|
|
type: String,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
description: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
status: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: undefined,
|
|
|
|
|
},
|
|
|
|
|
type: {
|
|
|
|
|
type: String,
|
|
|
|
|
required: true,
|
2024-10-21 11:48:25 +08:00
|
|
|
enum: ["http", "ping", "pagespeed", "hardware"],
|
2024-10-17 12:07:30 +08:00
|
|
|
},
|
|
|
|
|
url: {
|
|
|
|
|
type: String,
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
isActive: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: true,
|
|
|
|
|
},
|
|
|
|
|
interval: {
|
|
|
|
|
// in milliseconds
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 60000,
|
|
|
|
|
},
|
|
|
|
|
uptimePercentage: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: undefined,
|
|
|
|
|
},
|
|
|
|
|
notifications: [
|
|
|
|
|
{
|
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
|
ref: "Notification",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
timestamps: true,
|
|
|
|
|
}
|
2024-05-21 13:52:28 -07:00
|
|
|
);
|
2024-05-10 13:36:04 -07:00
|
|
|
|
2024-10-15 11:57:37 +08:00
|
|
|
export default mongoose.model("Monitor", MonitorSchema);
|