Merge pull request #72 from bluewave-labs/server/models

Added Check and Alert models and updated ReadMe
This commit is contained in:
Veysel
2024-05-27 17:48:09 -04:00
committed by GitHub
3 changed files with 85 additions and 0 deletions

View File

@@ -118,6 +118,35 @@ Example:
</details>
<details>
<summary><code>Check</code></summary>
| 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 |
</details>
<details>
<summary><code>Alert</code></summary>
| 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 |
</details>
---
<details>

28
Server/models/Alert.js Normal file
View File

@@ -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);

28
Server/models/Check.js Normal file
View File

@@ -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);