From 36936266acf35392dc737a42bcb71ba44e1b9993 Mon Sep 17 00:00:00 2001 From: veyselboybay Date: Mon, 27 May 2024 15:07:34 -0400 Subject: [PATCH] Added Check and Alert models and updated ReadMe --- README.md | 29 +++++++++++++++++++++++++++++ Server/models/Alert.js | 28 ++++++++++++++++++++++++++++ Server/models/Check.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 Server/models/Alert.js create mode 100644 Server/models/Check.js diff --git a/README.md b/README.md index a8e1b1f32..039750dc1 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,35 @@ Example: +
+Check + +| Name | Type | Notes | +| ----------- | --------- | ------------------------------------------------| +| monitorId | `string` | Unique ID for the monitor | +| status | `boolean` | Indicates the service is Up or Down | +| responseTime| `integer` | Indicates the response time of the service (ms) | +| statusCode | `integer` | Status Code returned from the service | +| message | `string` | Message returned from the service | +| updatedAt | `Date` | Last time the check was updated | +| CreatedAt | `Date` | When the check was created | + +
+ +
+Alert + +| Name | Type | Notes | +| ----------- | --------- | --------------------------------------------------| +| checkId | `string` | Unique ID for the check | +| status | `boolean` | Indicates the service is Up or Down | +| message | `string` | Message for the user about the down service | +| notifiedStatus | `boolean` | Indicates whether the user is notified | +| acknowledgeStatus | `boolean` | Indicates whether the user acknowledged the alert | +| updatedAt | `Date` | Last time the alert was updated | +| CreatedAt | `Date` | When the alert was created | + +
---
diff --git a/Server/models/Alert.js b/Server/models/Alert.js new file mode 100644 index 000000000..72705d947 --- /dev/null +++ b/Server/models/Alert.js @@ -0,0 +1,28 @@ +const mongoose = require('mongoose') + +const AlertSchema = mongoose.Schema( + { + checkId: { + type: mongoose.Schema.Types.ObjectId, + ref: 'Check', + immutable: true, + }, + status: { + type: Boolean, + }, + message: { + type: String, + }, + notifiedStatus: { + type: Boolean, + }, + acknowledgeStatus: { + type: Boolean, + } + }, + { + timestamps: true, + } +); + +module.exports = mongoose.model('Alert', AlertSchema); diff --git a/Server/models/Check.js b/Server/models/Check.js new file mode 100644 index 000000000..eedc2a28e --- /dev/null +++ b/Server/models/Check.js @@ -0,0 +1,28 @@ +const mongoose = require('mongoose') + +const CheckSchema = mongoose.Schema( + { + monitorId: { + type: mongoose.Schema.Types.ObjectId, + ref: 'Monitor', + immutable: true, + }, + status: { + type: Boolean, + }, + responseTime: { + type: Number, // milliseconds + }, + statusCode: { + type: Number, // 200, ... , 500 + }, + message: { + type: String, + } + }, + { + timestamps: true, + } +); + +module.exports = mongoose.model('Check', CheckSchema);