Merge branch 'bluewave-labs:master' into polishing-values
This commit is contained in:
11 files changed
+571
-175
No files matched your search
@@ -1,15 +1,20 @@
|
|||||||
|
.dashboard-menu-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.icon-container {
|
.icon-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-container {
|
.text-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard-menu-text {
|
.dashboard-menu-text {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
.dashboard-sidebar {
|
||||||
|
height: 100vh;
|
||||||
|
width: 250px;
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-container {
|
||||||
|
margin-top: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 10px 20px;
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.support-text {
|
||||||
|
margin-left: 8px;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import DashboardMenu from '../../Components/DashboardMenu';
|
||||||
|
import SupportIcon from '@mui/icons-material/Support';
|
||||||
|
import SvgIcon from '@mui/material/SvgIcon';
|
||||||
|
import './index.css';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @component
|
||||||
|
* DashboardSidebar component serves as a sidebar containing the DashboardMenu and a Support icon at the bottom.
|
||||||
|
*
|
||||||
|
* @returns {JSX.Element} The JSX element representing the DashboardSidebar component.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function DashboardSidebar() {
|
||||||
|
return (
|
||||||
|
<div className="dashboard-sidebar">
|
||||||
|
<div className="menu-container">
|
||||||
|
<DashboardMenu />
|
||||||
|
</div>
|
||||||
|
<div className="support-container">
|
||||||
|
<SvgIcon component={SupportIcon} />
|
||||||
|
<span className="support-text">Support</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DashboardSidebar;
|
||||||
@@ -46,8 +46,8 @@ function NavBar() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppBar position="static">
|
<AppBar position="fixed" sx={{ width: '100%' }}>
|
||||||
<Container maxWidth="xl">
|
<Container maxWidth="xxl" sx={{ width: '100%' }}>
|
||||||
<Toolbar disableGutters>
|
<Toolbar disableGutters>
|
||||||
<Typography
|
<Typography
|
||||||
variant="h6"
|
variant="h6"
|
||||||
|
|||||||
@@ -1 +1,11 @@
|
|||||||
/*Homelayout styles*/
|
.home-layout {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
margin-left: 250px;
|
||||||
|
flex: 1;
|
||||||
|
padding: 20px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,21 +1,17 @@
|
|||||||
import NavBar from '../../Components/NavBar'
|
import NavBar from '../../Components/NavBar';
|
||||||
import { Outlet } from 'react-router'
|
import { Outlet } from 'react-router';
|
||||||
import Home from '../../Pages/Home'
|
import DashboardSidebar from '../../Components/DashboardSidebar';
|
||||||
import './index.css'
|
import './index.css';
|
||||||
import ChartsOverviewDemo from '../../Components/DashboardProgressBars'
|
|
||||||
import DashboardSettings from '../../Components/DashboardSettingsIcon'
|
|
||||||
|
|
||||||
|
|
||||||
const HomeLayout = () => {
|
const HomeLayout = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="home-layout">
|
||||||
<NavBar />
|
<DashboardSidebar />
|
||||||
<Home />
|
<div className="main-content">
|
||||||
<Outlet />
|
<NavBar />
|
||||||
<ChartsOverviewDemo />
|
</div>
|
||||||
<DashboardSettings />
|
</div>
|
||||||
</>
|
);
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default HomeLayout
|
export default HomeLayout;
|
||||||
@@ -655,22 +655,54 @@ curl --request POST \
|
|||||||
|
|
||||||
###### Response Payload
|
###### Response Payload
|
||||||
|
|
||||||
> | Type | Notes |
|
> | Type | Notes |
|
||||||
> | ---- | ------------------- |
|
> | ------- | --------------------------- |
|
||||||
> | None | No payload returned |
|
> | `Check` | Returns newly created check |
|
||||||
|
|
||||||
###### Body
|
###### Body
|
||||||
|
|
||||||
|
> | Name | Type | Notes |
|
||||||
|
> | ------------ | --------- | -------------------------------------- |
|
||||||
|
> | monitorId | `string` | Monitor associated with Check |
|
||||||
|
> | status | `boolean` | `true` for up and `false` for down |
|
||||||
|
> | responseTime | `number` | How long it took the server to respond |
|
||||||
|
> | statusCode | `number` | HTTP Status code of response |
|
||||||
|
> | message | `string` | |
|
||||||
|
|
||||||
##### Sample CURL request
|
##### Sample CURL request
|
||||||
|
|
||||||
```
|
```
|
||||||
|
curl --request POST \
|
||||||
|
--url http://localhost:5000/api/v1/checks/66562414035c4ce6a8a610ac \
|
||||||
|
--header 'Authorization: <bearer_token>' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{
|
||||||
|
"monitorId": "66562414035c4ce6a8a610ac",
|
||||||
|
"status": true,
|
||||||
|
"responseTime": 1,
|
||||||
|
"statusCode": 200,
|
||||||
|
"message": "good"
|
||||||
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Sample Response
|
###### Sample Response
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"msg": "Check created",
|
||||||
|
"data": {
|
||||||
|
"monitorId": "66562414035c4ce6a8a610ac",
|
||||||
|
"status": true,
|
||||||
|
"responseTime": 1,
|
||||||
|
"statusCode": 200,
|
||||||
|
"message": "good",
|
||||||
|
"_id": "66576decba9f70148ea1f354",
|
||||||
|
"createdAt": "2024-05-29T18:03:24.445Z",
|
||||||
|
"updatedAt": "2024-05-29T18:03:24.445Z",
|
||||||
|
"__v": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@@ -682,7 +714,7 @@ curl --request POST \
|
|||||||
|
|
||||||
> | Method/Headers | Value |
|
> | Method/Headers | Value |
|
||||||
> | -------------- | ----- |
|
> | -------------- | ----- |
|
||||||
> | Method | POST |
|
> | Method | GET |
|
||||||
|
|
||||||
###### Response Payload
|
###### Response Payload
|
||||||
|
|
||||||
@@ -693,13 +725,42 @@ curl --request POST \
|
|||||||
##### Sample CURL request
|
##### Sample CURL request
|
||||||
|
|
||||||
```
|
```
|
||||||
|
curl --request GET \
|
||||||
|
--url http://localhost:5000/api/v1/checks/66562414035c4ce6a8a610ac \
|
||||||
|
--header 'Authorization: <bearer_token>' \
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Sample Response
|
###### Sample Response
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"msg": "Checks retrieved",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"_id": "66576c0194e11c0d4409d3c1",
|
||||||
|
"monitorId": "66562414035c4ce6a8a610ac",
|
||||||
|
"status": true,
|
||||||
|
"responseTime": 1,
|
||||||
|
"statusCode": 200,
|
||||||
|
"message": "good",
|
||||||
|
"createdAt": "2024-05-29T17:55:13.581Z",
|
||||||
|
"updatedAt": "2024-05-29T17:55:13.581Z",
|
||||||
|
"__v": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"_id": "66576c0994e11c0d4409d3c5",
|
||||||
|
"monitorId": "66562414035c4ce6a8a610ac",
|
||||||
|
"status": true,
|
||||||
|
"responseTime": 2,
|
||||||
|
"statusCode": 200,
|
||||||
|
"message": "good",
|
||||||
|
"createdAt": "2024-05-29T17:55:21.127Z",
|
||||||
|
"updatedAt": "2024-05-29T17:55:21.127Z",
|
||||||
|
"__v": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@@ -715,22 +776,28 @@ curl --request POST \
|
|||||||
|
|
||||||
###### Response Payload
|
###### Response Payload
|
||||||
|
|
||||||
> | Type | Notes |
|
> | Type | Notes |
|
||||||
> | ---- | ------------------- |
|
> | -------- | -------------------------------------------------------------------- |
|
||||||
> | None | No payload returned |
|
> | `Object` | `{deletedCount: n}` Returns an object showing how many items deleted |
|
||||||
|
|
||||||
###### Body
|
|
||||||
|
|
||||||
##### Sample CURL request
|
##### Sample CURL request
|
||||||
|
|
||||||
```
|
```
|
||||||
|
curl --request POST \
|
||||||
|
--url http://localhost:5000/api/v1/checks/delete/66562414035c4ce6a8a610ac \
|
||||||
|
--header 'Authorization: <bearer_token>' \
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Sample Response
|
###### Sample Response
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"msg": "Checks deleted",
|
||||||
|
"data": {
|
||||||
|
"deletedCount": 3
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@@ -756,6 +823,24 @@ curl --request POST \
|
|||||||
|
|
||||||
###### Body
|
###### Body
|
||||||
|
|
||||||
|
"checkId": "66577a3fd16dcf7c1ce35148",
|
||||||
|
"monitorId": "6657789ebf6766ee8e2d2edb",
|
||||||
|
"userId": "6654d1a2634754f789e1f115",
|
||||||
|
"status": false,
|
||||||
|
"message": "This is a test alert",
|
||||||
|
"notifiedStatus": "false",
|
||||||
|
"acknowledgeStatus": false
|
||||||
|
|
||||||
|
> | Name | Type | Notes |
|
||||||
|
> | ----------------- | --------- | --------------------------------------- |
|
||||||
|
> | checkId | `string` | Id of `Check` associated with `Alert` |
|
||||||
|
> | monitorId | `string` | Id of `Monitor` associated with `Alert` |
|
||||||
|
> | userId | `string` | Id of `User` associated with `Alert` |
|
||||||
|
> | status | `boolean` | Status of `Alert` |
|
||||||
|
> | message | `string` | `Alert` message |
|
||||||
|
> | notifiedStatus | `boolean` | |
|
||||||
|
> | acknowledgeStatus | `boolean` | |
|
||||||
|
|
||||||
##### Sample CURL request
|
##### Sample CURL request
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -788,13 +873,33 @@ curl --request POST \
|
|||||||
##### Sample CURL request
|
##### Sample CURL request
|
||||||
|
|
||||||
```
|
```
|
||||||
|
curl --request GET \
|
||||||
|
--url http://localhost:5000/api/v1/alerts/user/6654d1a2634754f789e1f115 \
|
||||||
|
--header 'Authorization: <bearer_token>'
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Sample Response
|
###### Sample Response
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"msg": "Got alerts",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"_id": "6657813d809adfded891a6b7",
|
||||||
|
"checkId": "66577a3fd16dcf7c1ce35148",
|
||||||
|
"monitorId": "6657789ebf6766ee8e2d2edb",
|
||||||
|
"userId": "6654d1a2634754f789e1f115",
|
||||||
|
"status": false,
|
||||||
|
"message": "This is a test alert",
|
||||||
|
"notifiedStatus": false,
|
||||||
|
"acknowledgeStatus": false,
|
||||||
|
"createdAt": "2024-05-29T19:25:49.317Z",
|
||||||
|
"updatedAt": "2024-05-29T19:25:49.317Z",
|
||||||
|
"__v": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@@ -816,13 +921,33 @@ curl --request POST \
|
|||||||
##### Sample CURL request
|
##### Sample CURL request
|
||||||
|
|
||||||
```
|
```
|
||||||
|
curl --request GET \
|
||||||
|
--url http://localhost:5000/api/v1/alerts/monitor/6657789ebf6766ee8e2d2edb \
|
||||||
|
--header 'Authorization: <bearer_token>' \
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Sample Response
|
###### Sample Response
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"msg": "Got alerts by Monitor",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"_id": "6657813d809adfded891a6b7",
|
||||||
|
"checkId": "66577a3fd16dcf7c1ce35148",
|
||||||
|
"monitorId": "6657789ebf6766ee8e2d2edb",
|
||||||
|
"userId": "6654d1a2634754f789e1f115",
|
||||||
|
"status": false,
|
||||||
|
"message": "This is a test alert",
|
||||||
|
"notifiedStatus": false,
|
||||||
|
"acknowledgeStatus": false,
|
||||||
|
"createdAt": "2024-05-29T19:25:49.317Z",
|
||||||
|
"updatedAt": "2024-05-29T19:25:49.317Z",
|
||||||
|
"__v": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@@ -845,13 +970,31 @@ curl --request POST \
|
|||||||
##### Sample CURL request
|
##### Sample CURL request
|
||||||
|
|
||||||
```
|
```
|
||||||
|
curl --request GET \
|
||||||
|
--url http://localhost:5000/api/v1/alerts/66577ddae5ff3c91437d0887 \
|
||||||
|
--header 'Authorization: <bearer_token>' \
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Sample Response
|
###### Sample Response
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"msg": "Got Alert By alertID",
|
||||||
|
"data": {
|
||||||
|
"_id": "66577ddae5ff3c91437d0887",
|
||||||
|
"checkId": "66577a3fd16dcf7c1ce35148",
|
||||||
|
"monitorId": "6657789ebf6766ee8e2d2edb",
|
||||||
|
"userId": "6654d1a2634754f789e1f115",
|
||||||
|
"status": false,
|
||||||
|
"message": "This is a test alert",
|
||||||
|
"notifiedStatus": false,
|
||||||
|
"acknowledgeStatus": false,
|
||||||
|
"createdAt": "2024-05-29T19:11:22.205Z",
|
||||||
|
"updatedAt": "2024-05-29T19:11:22.205Z",
|
||||||
|
"__v": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@@ -867,22 +1010,54 @@ curl --request POST \
|
|||||||
|
|
||||||
###### Response Payload
|
###### Response Payload
|
||||||
|
|
||||||
> | Type | Notes |
|
> | Type | Notes |
|
||||||
> | ------- | -------------------- |
|
> | ------- | ---------------------- |
|
||||||
> | `Alert` | Returns edited alert |
|
> | `Alert` | Returns edited `Alert` |
|
||||||
|
|
||||||
###### Body
|
###### Body
|
||||||
|
|
||||||
|
> | Name | Type | Notes |
|
||||||
|
> | ----------------- | --------- | ------------------------------------------ |
|
||||||
|
> | checkId | `string` | ID of `Check` associated with `Alert` |
|
||||||
|
> | monitorId | `string` | ID of `Monitor` id associated with `Alert` |
|
||||||
|
> | userId | `string` | ID of `User` associated with `Alert` |
|
||||||
|
> | status | `boolean` | Alert status |
|
||||||
|
> | message | `string` | Alert message |
|
||||||
|
> | notifiedStatus | `boolean` | |
|
||||||
|
> | acknowledgeStatus | `boolean` | |
|
||||||
|
|
||||||
##### Sample CURL request
|
##### Sample CURL request
|
||||||
|
|
||||||
```
|
```
|
||||||
|
curl --request POST \
|
||||||
|
--url http://localhost:5000/api/v1/alerts/edit/66577ddae5ff3c91437d0887 \
|
||||||
|
--header 'Authorization: <bearer_token>' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{
|
||||||
|
"acknowledgeStatus": true
|
||||||
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Sample Response
|
###### Sample Response
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"msg": "Edited alert",
|
||||||
|
"data": {
|
||||||
|
"_id": "66577ddae5ff3c91437d0887",
|
||||||
|
"checkId": "66577a3fd16dcf7c1ce35148",
|
||||||
|
"monitorId": "6657789ebf6766ee8e2d2edb",
|
||||||
|
"userId": "6654d1a2634754f789e1f115",
|
||||||
|
"status": false,
|
||||||
|
"message": "This is a test alert",
|
||||||
|
"notifiedStatus": false,
|
||||||
|
"acknowledgeStatus": true,
|
||||||
|
"createdAt": "2024-05-29T19:11:22.205Z",
|
||||||
|
"updatedAt": "2024-05-29T19:12:23.951Z",
|
||||||
|
"__v": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@@ -897,22 +1072,38 @@ curl --request POST \
|
|||||||
|
|
||||||
###### Response Payload
|
###### Response Payload
|
||||||
|
|
||||||
> | Type | Notes |
|
> | Type | Notes |
|
||||||
> | ---- | ------------------- |
|
> | ------- | --------------------------- |
|
||||||
> | None | No payload returned |
|
> | `Alert` | Returns the deleted `Alert` |
|
||||||
|
|
||||||
###### Body
|
|
||||||
|
|
||||||
##### Sample CURL request
|
##### Sample CURL request
|
||||||
|
|
||||||
```
|
```
|
||||||
|
curl --request POST \
|
||||||
|
--url http://localhost:5000/api/v1/alerts/delete/66577ddae5ff3c91437d0887 \
|
||||||
|
--header 'Authorization: <bearer_token>' \
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Sample Response
|
###### Sample Response
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"msg": "Deleted alert",
|
||||||
|
"data": {
|
||||||
|
"_id": "66577ddae5ff3c91437d0887",
|
||||||
|
"checkId": "66577a3fd16dcf7c1ce35148",
|
||||||
|
"monitorId": "6657789ebf6766ee8e2d2edb",
|
||||||
|
"userId": "6654d1a2634754f789e1f115",
|
||||||
|
"status": false,
|
||||||
|
"message": "This is a test alert",
|
||||||
|
"notifiedStatus": false,
|
||||||
|
"acknowledgeStatus": true,
|
||||||
|
"createdAt": "2024-05-29T19:11:22.205Z",
|
||||||
|
"updatedAt": "2024-05-29T19:12:23.951Z",
|
||||||
|
"__v": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const {
|
|||||||
editAlertBodyValidation,
|
editAlertBodyValidation,
|
||||||
deleteAlertParamValidation,
|
deleteAlertParamValidation,
|
||||||
} = require("../validation/joi");
|
} = require("../validation/joi");
|
||||||
|
const { get } = require("mongoose");
|
||||||
|
|
||||||
const SERVICE_NAME = "alerts";
|
const SERVICE_NAME = "alerts";
|
||||||
|
|
||||||
@@ -35,7 +36,11 @@ const createAlert = async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
req.db.createAlert(req, res);
|
const alertData = { ...req.body };
|
||||||
|
const alert = await req.db.createAlert(alertData);
|
||||||
|
return res
|
||||||
|
.status(200)
|
||||||
|
.json({ success: true, msg: "Alert created", data: alert });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
next(error);
|
next(error);
|
||||||
@@ -62,7 +67,10 @@ const getAlertsByUserId = async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
req.db.getAlertsByUserId(req, res);
|
const alerts = await req.db.getAlertsByUserId(req.params.userId);
|
||||||
|
return res
|
||||||
|
.status(200)
|
||||||
|
.json({ success: true, msg: "Got alerts", data: alerts });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
next(error);
|
next(error);
|
||||||
@@ -72,29 +80,30 @@ const getAlertsByUserId = async (req, res, next) => {
|
|||||||
const getAlertsByMonitorId = async (req, res, next) => {
|
const getAlertsByMonitorId = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
await getAlertsByMonitorIdParamValidation.validateAsync(req.params);
|
await getAlertsByMonitorIdParamValidation.validateAsync(req.params);
|
||||||
res.status(200).json({
|
|
||||||
success: true,
|
|
||||||
msg: "Get Alerts By MonitorID",
|
|
||||||
data: req.params.monitorId,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.status = 422;
|
error.status = 422;
|
||||||
res.status(200).json({ success: true, msg: "Edit alert" });
|
|
||||||
|
|
||||||
error.message = error.details[0].message;
|
error.message = error.details[0].message;
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
next(error);
|
next(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const alerts = await req.db.getAlertsByMonitorId(req.params.monitorId);
|
||||||
|
return res.status(200).json({
|
||||||
|
success: true,
|
||||||
|
msg: "Got alerts by Monitor",
|
||||||
|
data: alerts,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAlertById = async (req, res, next) => {
|
const getAlertById = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
await getAlertByIdParamValidation.validateAsync(req.params);
|
await getAlertByIdParamValidation.validateAsync(req.params);
|
||||||
res.status(200).json({
|
|
||||||
success: true,
|
|
||||||
msg: "Get Alert By alertID",
|
|
||||||
data: req.params.alertId,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.status = 422;
|
error.status = 422;
|
||||||
error.message = error.details[0].message;
|
error.message = error.details[0].message;
|
||||||
@@ -102,24 +111,49 @@ const getAlertById = async (req, res, next) => {
|
|||||||
next(error);
|
next(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const alert = await req.db.getAlertById(req.params.alertId);
|
||||||
|
return res.status(200).json({
|
||||||
|
success: true,
|
||||||
|
msg: "Got Alert By alertID",
|
||||||
|
data: alert,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const editAlert = async (req, res, next) => {
|
const editAlert = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
await editAlertParamValidation(req.params);
|
await editAlertParamValidation.validateAsync(req.params);
|
||||||
await editAlertBodyValidation(req.body);
|
await editAlertBodyValidation.validateAsync(req.body);
|
||||||
res.status(200).json({ success: true, msg: "Edit alert" });
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
error.status = 422;
|
error.status = 422;
|
||||||
error.message = error.details[0].message;
|
error.message = error.details[0].message;
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
next(error);
|
next(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const alertData = { ...req.body };
|
||||||
|
const alert = await req.db.editAlert(req.params.alertId, alertData);
|
||||||
|
return res.status(200).json({
|
||||||
|
success: true,
|
||||||
|
msg: "Edited alert",
|
||||||
|
data: alert,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const deleteAlert = async (req, res, next) => {
|
const deleteAlert = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
await deleteAlertParamValidation(req.params);
|
await deleteAlertParamValidation.validateAsync(req.params);
|
||||||
res.status(200).json({ success: true, msg: "Delete alert" });
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.status = 422;
|
error.status = 422;
|
||||||
error.message = error.details[0].message;
|
error.message = error.details[0].message;
|
||||||
@@ -127,6 +161,18 @@ const deleteAlert = async (req, res, next) => {
|
|||||||
next(error);
|
next(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const deleted = await req.db.deleteAlert(req.params.alertId);
|
||||||
|
return res.status(200).json({
|
||||||
|
success: true,
|
||||||
|
msg: "Deleted alert",
|
||||||
|
data: deleted,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -1,29 +1,73 @@
|
|||||||
var jwt = require("jsonwebtoken");
|
const {
|
||||||
|
createCheckParamValidation,
|
||||||
|
createCheckBodyValidation,
|
||||||
|
getChecksParamValidation,
|
||||||
|
deleteChecksParamValidation,
|
||||||
|
} = require("../validation/joi");
|
||||||
const SERVICE_NAME = "check";
|
const SERVICE_NAME = "check";
|
||||||
|
|
||||||
const createCheck = (req, res, next) => {
|
const createCheck = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
req.db.createCheck(req, res);
|
await createCheckParamValidation.validateAsync(req.params);
|
||||||
|
await createCheckBodyValidation.validateAsync(req.body);
|
||||||
|
} catch (error) {
|
||||||
|
error.status = 422;
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.message = error.details[0].message;
|
||||||
|
next(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const checkData = { ...req.body };
|
||||||
|
const check = await req.db.createCheck(checkData);
|
||||||
|
return res
|
||||||
|
.status(200)
|
||||||
|
.json({ success: true, msg: "Check created", data: check });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getChecks = (req, res, next) => {
|
const getChecks = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
req.db.getChecks(req, res);
|
await getChecksParamValidation.validateAsync(req.params);
|
||||||
// Return all checks for a monitor
|
} catch (error) {
|
||||||
|
error.status = 422;
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.message = error.details[0].message;
|
||||||
|
next(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const checks = await req.db.getChecks(req.params.monitorId);
|
||||||
|
return res
|
||||||
|
.status(200)
|
||||||
|
.json({ success: true, msg: "Checks retrieved", data: checks });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteChecks = (req, res, next) => {
|
const deleteChecks = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
req.db.deleteChecks(req, res);
|
await deleteChecksParamValidation.validateAsync(req.params);
|
||||||
// Delete all checks for a monitor
|
} catch (error) {
|
||||||
|
error.status = 422;
|
||||||
|
error.service = SERVICE_NAME;
|
||||||
|
error.message = error.details[0].message;
|
||||||
|
next(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const deletedCount = await req.db.deleteChecks(req.params.monitorId);
|
||||||
|
return res
|
||||||
|
.status(200)
|
||||||
|
.json({ success: true, msg: "Checks deleted", data: { deletedCount } });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
next(error);
|
next(error);
|
||||||
|
|||||||
+77
-71
@@ -1,6 +1,8 @@
|
|||||||
const Monitor = require("../models/Monitor");
|
const Monitor = require("../models/Monitor");
|
||||||
const mongoose = require("mongoose");
|
const mongoose = require("mongoose");
|
||||||
const UserModel = require("../models/user");
|
const UserModel = require("../models/user");
|
||||||
|
const Check = require("../models/Check");
|
||||||
|
const Alert = require("../models/Alert");
|
||||||
|
|
||||||
const verifyId = (userId, monitorId) => {
|
const verifyId = (userId, monitorId) => {
|
||||||
return userId.toString() === monitorId.toString();
|
return userId.toString() === monitorId.toString();
|
||||||
@@ -59,10 +61,6 @@ const getUserByEmail = async (req, res) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//****************************************
|
|
||||||
// Monitors
|
|
||||||
//****************************************
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a user by ID
|
* Update a user by ID
|
||||||
* @async
|
* @async
|
||||||
@@ -88,6 +86,10 @@ const updateUser = async (req, res) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//****************************************
|
||||||
|
// Monitors
|
||||||
|
//****************************************
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all monitors
|
* Get all monitors
|
||||||
* @async
|
* @async
|
||||||
@@ -209,17 +211,21 @@ const editMonitor = async (req, res) => {
|
|||||||
/**
|
/**
|
||||||
* Create a check for a monitor
|
* Create a check for a monitor
|
||||||
* @async
|
* @async
|
||||||
* @param {Express.Request} req
|
* @param {Object} checkData
|
||||||
* @param {Express.Response} res
|
* @param {string} checkData.monitorId
|
||||||
|
* @param {boolean} checkData.status
|
||||||
|
* @param {number} checkData.responseTime
|
||||||
|
* @param {number} checkData.statusCode
|
||||||
|
* @param {string} checkData.message
|
||||||
|
* @returns {Promise<Check>}
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const createCheck = async (req, res) => {
|
const createCheck = async (checkData) => {
|
||||||
try {
|
try {
|
||||||
// Create check with monitor id
|
console.log(checkData);
|
||||||
res
|
const check = await new Check({ ...checkData }).save();
|
||||||
.status(200)
|
return check;
|
||||||
.json({ success: true, msg: "Create check", data: req.params.monitorId });
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -228,17 +234,15 @@ const createCheck = async (req, res) => {
|
|||||||
/**
|
/**
|
||||||
* Get all checks for a monitor
|
* Get all checks for a monitor
|
||||||
* @async
|
* @async
|
||||||
* @param {Express.Request} req
|
* @param {string} monitorId
|
||||||
* @param {Express.Response} res
|
* @returns {Promise<Array<Check>>}
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const getChecks = async (req, res) => {
|
const getChecks = async (monitorId) => {
|
||||||
try {
|
try {
|
||||||
// TODO get all checks for a monitor from DB
|
const checks = await Check.find({ monitorId });
|
||||||
res
|
return checks;
|
||||||
.status(200)
|
|
||||||
.json({ success: true, msg: "Get checks", data: req.params.monitorId });
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -247,19 +251,19 @@ const getChecks = async (req, res) => {
|
|||||||
/**
|
/**
|
||||||
* Delete all checks for a monitor
|
* Delete all checks for a monitor
|
||||||
* @async
|
* @async
|
||||||
* @param {Express.Request} req
|
* @param {string} monitorId
|
||||||
* @param {Express.Response} res
|
* @returns {number}
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const deleteChecks = async (req, res) => {
|
const deleteChecks = async (monitorId) => {
|
||||||
try {
|
try {
|
||||||
// TODO Delete all checks for a monitor
|
const result = await Check.deleteMany({ monitorId });
|
||||||
res.status(200).json({
|
if (result.deletedCount > 0) {
|
||||||
success: true,
|
return result.deletedCount;
|
||||||
msg: "Deleted checks",
|
} else {
|
||||||
data: req.params.monitorId,
|
throw new Error(`No checks found for monitor with id ${monitorId}`);
|
||||||
});
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -272,16 +276,21 @@ const deleteChecks = async (req, res) => {
|
|||||||
/**
|
/**
|
||||||
* Creates an Alert associated with a Monitor and User
|
* Creates an Alert associated with a Monitor and User
|
||||||
* @async
|
* @async
|
||||||
* @param {Express.Request} req
|
* @param {Object} alertData
|
||||||
* @param {Express.Response} res
|
* @param {string} alertData.checkId
|
||||||
|
* @param {string} alert.monitorId
|
||||||
|
* @param {string} alert.userId
|
||||||
|
* @param {boolean} alert.status
|
||||||
|
* @param {string} alert.message
|
||||||
|
* @param {boolean} alert.notifiedStatus
|
||||||
|
* @param {boolean} alert.acknowledgeStatus
|
||||||
* @returns {<Promise<Alert>>}
|
* @returns {<Promise<Alert>>}
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
const createAlert = async (req, res) => {
|
const createAlert = async (alertData) => {
|
||||||
try {
|
try {
|
||||||
res
|
const alert = await new Alert({ ...alertData }).save();
|
||||||
.status(200)
|
return alert;
|
||||||
.json({ success: true, msg: "Create Alert", data: req.params.monitorId });
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -290,18 +299,14 @@ const createAlert = async (req, res) => {
|
|||||||
/**
|
/**
|
||||||
* Gets all alerts a User has set
|
* Gets all alerts a User has set
|
||||||
* @async
|
* @async
|
||||||
* @param {Express.Request} req
|
* @param {string} userId
|
||||||
* @param {Express.Response} res
|
|
||||||
* @returns {<Promise<Array<Alert>>}
|
* @returns {<Promise<Array<Alert>>}
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
const getAlertsByUserId = async (req, res) => {
|
const getAlertsByUserId = async (userId) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).json({
|
const alerts = await Alert.find({ userId });
|
||||||
success: true,
|
return alerts;
|
||||||
msg: "Get Alerts By UserID",
|
|
||||||
data: req.params.userId,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -310,73 +315,74 @@ const getAlertsByUserId = async (req, res) => {
|
|||||||
/**
|
/**
|
||||||
* Gets all alerts a for an associated Monitor
|
* Gets all alerts a for an associated Monitor
|
||||||
* @async
|
* @async
|
||||||
* @param {Express.Request} req
|
* @param {string} monitorId
|
||||||
* @param {Express.Response} res
|
|
||||||
* @returns {<Promise<Array<Alert>>}
|
* @returns {<Promise<Array<Alert>>}
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
const getAlertsByMonitorId = async (req, res) => {
|
const getAlertsByMonitorId = async (monitorId) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).json({
|
const alerts = await Alert.find({ monitorId });
|
||||||
success: true,
|
return alerts;
|
||||||
msg: "Get Alerts By MonitorID",
|
|
||||||
data: req.params.monitorId,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an alert with specified ID
|
* Returns an alert with specified ID
|
||||||
* @async
|
* @async
|
||||||
* @param {Express.Request} req
|
* @param {string} alertId
|
||||||
* @param {Express.Response} res
|
|
||||||
* @returns {Promise<Alert>}
|
* @returns {Promise<Alert>}
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
const getAlertById = async (req, res) => {
|
const getAlertById = async (alertId) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).json({
|
const alert = await Alert.findById(alertId);
|
||||||
success: true,
|
return alert;
|
||||||
msg: "Get Alert By alertID",
|
|
||||||
data: req.params.alertId,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an edited monitor with the specified ID
|
* Returns an edited alert with the specified ID
|
||||||
* @async
|
* @async
|
||||||
* @param {Express.Request} req
|
* @param {string} alertId
|
||||||
|
* @param {Object} alertData
|
||||||
|
* @param {string} alertData.checkId
|
||||||
|
* @param {string} alertData.monitorId
|
||||||
|
* @param {string} alertData.userId
|
||||||
|
* @param {boolean} alertData.status
|
||||||
|
* @param {string} alertData.message
|
||||||
|
* @param {boolean} alertData.notifiedStatus
|
||||||
|
* @param {boolean} alertData.acknowledgeStatus
|
||||||
* @param {Express.Response} res
|
* @param {Express.Response} res
|
||||||
* @returns {Promise<Alert>>}
|
* @returns {Promise<Alert>>}
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
const editAlert = async (req, res) => {
|
const editAlert = async (alertId, alertData) => {
|
||||||
try {
|
try {
|
||||||
res
|
const editedAlert = await Alert.findByIdAndUpdate(alertId, alertData, {
|
||||||
.status(200)
|
new: true,
|
||||||
.json({ success: true, msg: "Edit alert", data: req.params.alertId });
|
});
|
||||||
|
return editedAlert;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a monitor with the specified ID
|
* Deletes an alert with the specified ID
|
||||||
* @async
|
* @async
|
||||||
* @param {Express.Request} req
|
* @param {string} alertId
|
||||||
* @param {Express.Response} res
|
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
const deleteAlert = async (req, res) => {
|
const deleteAlert = async (alertId) => {
|
||||||
try {
|
try {
|
||||||
res
|
const result = await Alert.findByIdAndDelete(alertId);
|
||||||
.status(200)
|
if (result) {
|
||||||
.json({ success: true, msg: "Delete alert", data: req.params.alertId });
|
return result;
|
||||||
|
} else throw new Error(`Alert with id ${alertId} not found`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
const joi = require("joi");
|
const joi = require("joi");
|
||||||
|
|
||||||
|
//****************************************
|
||||||
|
// Auth
|
||||||
|
//****************************************
|
||||||
|
|
||||||
const loginValidation = joi.object({
|
const loginValidation = joi.object({
|
||||||
email: joi.string().email().required(),
|
email: joi.string().email().required(),
|
||||||
password: joi.string().min(8).required(),
|
password: joi.string().min(8).required(),
|
||||||
@@ -11,6 +15,20 @@ const registerValidation = joi.object({
|
|||||||
password: joi.string().min(8).required(),
|
password: joi.string().min(8).required(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const editUserParamValidation = joi.object({
|
||||||
|
userId: joi.string().required(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const editUserBodyValidation = joi.object({
|
||||||
|
firstname: joi.string(),
|
||||||
|
lastname: joi.string(),
|
||||||
|
profilePicUrl: joi.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
//****************************************
|
||||||
|
// Monitors
|
||||||
|
//****************************************
|
||||||
|
|
||||||
const getMonitorByIdValidation = joi.object({
|
const getMonitorByIdValidation = joi.object({
|
||||||
monitorId: joi.string().required(),
|
monitorId: joi.string().required(),
|
||||||
});
|
});
|
||||||
@@ -29,15 +47,9 @@ const monitorValidation = joi.object({
|
|||||||
interval: joi.number(),
|
interval: joi.number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const editUserParamValidation = joi.object({
|
//****************************************
|
||||||
userId: joi.string().required(),
|
// Alerts
|
||||||
});
|
//****************************************
|
||||||
|
|
||||||
const editUserBodyValidation = joi.object({
|
|
||||||
firstname: joi.string(),
|
|
||||||
lastname: joi.string(),
|
|
||||||
profilePicUrl: joi.string(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const createAlertParamValidation = joi.object({
|
const createAlertParamValidation = joi.object({
|
||||||
monitorId: joi.string().required(),
|
monitorId: joi.string().required(),
|
||||||
@@ -80,6 +92,30 @@ const deleteAlertParamValidation = joi.object({
|
|||||||
alertId: joi.string().required(),
|
alertId: joi.string().required(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//****************************************
|
||||||
|
// Checks
|
||||||
|
//****************************************
|
||||||
|
|
||||||
|
const createCheckParamValidation = joi.object({
|
||||||
|
monitorId: joi.string().required(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const createCheckBodyValidation = joi.object({
|
||||||
|
monitorId: joi.string().required(),
|
||||||
|
status: joi.boolean().required(),
|
||||||
|
responseTime: joi.number().required(),
|
||||||
|
statusCode: joi.number().required(),
|
||||||
|
message: joi.string().required(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const getChecksParamValidation = joi.object({
|
||||||
|
monitorId: joi.string().required(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const deleteChecksParamValidation = joi.object({
|
||||||
|
monitorId: joi.string().required(),
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
loginValidation,
|
loginValidation,
|
||||||
registerValidation,
|
registerValidation,
|
||||||
@@ -96,4 +132,8 @@ module.exports = {
|
|||||||
editAlertParamValidation,
|
editAlertParamValidation,
|
||||||
editAlertBodyValidation,
|
editAlertBodyValidation,
|
||||||
deleteAlertParamValidation,
|
deleteAlertParamValidation,
|
||||||
|
createCheckParamValidation,
|
||||||
|
createCheckBodyValidation,
|
||||||
|
getChecksParamValidation,
|
||||||
|
deleteChecksParamValidation,
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user