Updated validatio nand edit monitor
This commit is contained in:
1 parent
3f65973f0c
commit
d774f36b22
3 files changed
+72
-51
No files matched your search
@@ -497,9 +497,10 @@ curl --request POST \
|
|||||||
|
|
||||||
###### Method/Headers
|
###### Method/Headers
|
||||||
|
|
||||||
> | Method/Headers | Value |
|
> | Method/Headers | Value |
|
||||||
> | -------------- | ----- |
|
> | -------------- | ---------------- |
|
||||||
> | Method | GET |
|
> | Method | GET |
|
||||||
|
> | content-type | application/json |
|
||||||
|
|
||||||
###### Response Payload
|
###### Response Payload
|
||||||
|
|
||||||
@@ -545,9 +546,10 @@ curl --request GET \
|
|||||||
|
|
||||||
###### Method/Headers
|
###### Method/Headers
|
||||||
|
|
||||||
> | Method/Headers | Value |
|
> | Method/Headers | Value |
|
||||||
> | -------------- | ----- |
|
> | -------------- | ---------------- |
|
||||||
> | Method | POST |
|
> | Method | POST |
|
||||||
|
> | content-type | application/json |
|
||||||
|
|
||||||
##### Body
|
##### Body
|
||||||
|
|
||||||
@@ -568,7 +570,7 @@ curl --request POST \
|
|||||||
--url http://localhost:5000/api/v1/auth/recovery/request \
|
--url http://localhost:5000/api/v1/auth/recovery/request \
|
||||||
--header 'Content-Type: application/json' \
|
--header 'Content-Type: application/json' \
|
||||||
--data '{
|
--data '{
|
||||||
"email" : "ajhollid@gmail.com"
|
"email" : "name@gmail.com"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -579,7 +581,7 @@ curl --request POST \
|
|||||||
"success": true,
|
"success": true,
|
||||||
"msg": "Created recovery token",
|
"msg": "Created recovery token",
|
||||||
"data": {
|
"data": {
|
||||||
"email": "your_email@gmail.com",
|
"email": "name@gmail.com",
|
||||||
"token": "f519da5e4a9be40cfc3c0fde97e60c0e6d17bdaa613f5ba537a45073f3865193",
|
"token": "f519da5e4a9be40cfc3c0fde97e60c0e6d17bdaa613f5ba537a45073f3865193",
|
||||||
"_id": "6668878263587f30748e968e",
|
"_id": "6668878263587f30748e968e",
|
||||||
"expiry": "2024-06-11T17:21:06.984Z",
|
"expiry": "2024-06-11T17:21:06.984Z",
|
||||||
@@ -597,9 +599,10 @@ curl --request POST \
|
|||||||
|
|
||||||
###### Method/Headers
|
###### Method/Headers
|
||||||
|
|
||||||
> | Method/Headers | Value |
|
> | Method/Headers | Value |
|
||||||
> | -------------- | ----- |
|
> | -------------- | ---------------- |
|
||||||
> | Method | POST |
|
> | Method | POST |
|
||||||
|
> | content-type | application/json |
|
||||||
|
|
||||||
##### Body
|
##### Body
|
||||||
|
|
||||||
@@ -632,7 +635,7 @@ curl --request POST \
|
|||||||
"msg": "Token is valid",
|
"msg": "Token is valid",
|
||||||
"data": {
|
"data": {
|
||||||
"_id": "6668894263587f30748e969a",
|
"_id": "6668894263587f30748e969a",
|
||||||
"email": "ajhollid@gmail.com",
|
"email": "name@gmail.com",
|
||||||
"token": "457d9926b24dedf613f120eeb524ef00ac45b3f0fc5c70bd25b1cc8aa83a64a0",
|
"token": "457d9926b24dedf613f120eeb524ef00ac45b3f0fc5c70bd25b1cc8aa83a64a0",
|
||||||
"expiry": "2024-06-11T17:28:34.349Z",
|
"expiry": "2024-06-11T17:28:34.349Z",
|
||||||
"createdAt": "2024-06-11T17:28:34.349Z",
|
"createdAt": "2024-06-11T17:28:34.349Z",
|
||||||
@@ -649,9 +652,10 @@ curl --request POST \
|
|||||||
|
|
||||||
###### Method/Headers
|
###### Method/Headers
|
||||||
|
|
||||||
> | Method/Headers | Value |
|
> | Method/Headers | Value |
|
||||||
> | -------------- | ----- |
|
> | -------------- | ---------------- |
|
||||||
> | Method | POST |
|
> | Method | POST |
|
||||||
|
> | content-type | application/json |
|
||||||
|
|
||||||
##### Body
|
##### Body
|
||||||
|
|
||||||
@@ -686,9 +690,9 @@ curl --request POST \
|
|||||||
"msg": "Password reset",
|
"msg": "Password reset",
|
||||||
"data": {
|
"data": {
|
||||||
"_id": "66675891cb17336d84c25d9f",
|
"_id": "66675891cb17336d84c25d9f",
|
||||||
"firstname": "User First Name",
|
"firstname": "First Name",
|
||||||
"lastname": "User Last Name",
|
"lastname": "Last Name",
|
||||||
"email": "your_email@gmail.com",
|
"email": "name@gmail.com",
|
||||||
"isActive": true,
|
"isActive": true,
|
||||||
"isVerified": false,
|
"isVerified": false,
|
||||||
"createdAt": "2024-06-10T19:48:33.863Z",
|
"createdAt": "2024-06-10T19:48:33.863Z",
|
||||||
@@ -709,9 +713,10 @@ curl --request POST \
|
|||||||
|
|
||||||
##### Method/Headers
|
##### Method/Headers
|
||||||
|
|
||||||
> | Method/Headers | Value |
|
> | Method/Headers | Value |
|
||||||
> | -------------- | ----- |
|
> | -------------- | ---------------- |
|
||||||
> | Method | GET |
|
> | Method | GET |
|
||||||
|
> | content-type | application/json |
|
||||||
|
|
||||||
##### Response Payload
|
##### Response Payload
|
||||||
|
|
||||||
@@ -769,9 +774,10 @@ curl --request GET \
|
|||||||
|
|
||||||
###### Method/Headers
|
###### Method/Headers
|
||||||
|
|
||||||
> | Method/Headers | Value |
|
> | Method/Headers | Value |
|
||||||
> | -------------- | ----- |
|
> | -------------- | ---------------- |
|
||||||
> | Method | GET |
|
> | Method | GET |
|
||||||
|
> | content-type | application/json |
|
||||||
|
|
||||||
###### Response Payload
|
###### Response Payload
|
||||||
|
|
||||||
@@ -840,9 +846,10 @@ curl --request GET \
|
|||||||
|
|
||||||
###### Method/Headers
|
###### Method/Headers
|
||||||
|
|
||||||
> | Method/Headers | Value |
|
> | Method/Headers | Value |
|
||||||
> | -------------- | ----- |
|
> | -------------- | ---------------- |
|
||||||
> | Method | GET |
|
> | Method | GET |
|
||||||
|
> | content-type | application/json |
|
||||||
|
|
||||||
###### Response Payload
|
###### Response Payload
|
||||||
|
|
||||||
@@ -902,21 +909,22 @@ curl --request GET \
|
|||||||
|
|
||||||
###### Method/Headers
|
###### Method/Headers
|
||||||
|
|
||||||
> | Method/Headers | Value |
|
> | Method/Headers | Value |
|
||||||
> | -------------- | ----- |
|
> | -------------- | ---------------- |
|
||||||
> | Method | POST |
|
> | Method | POST |
|
||||||
|
> | content-type | application/json |
|
||||||
|
|
||||||
##### Body
|
##### Body
|
||||||
|
|
||||||
> | Name | Type | Notes | Accepted Values |
|
> | Name | Type | Notes | Accepted Values |
|
||||||
> | ----------- | --------- | ---------------------- | ---------------------- |
|
> | ----------- | --------- | ---------------------- | --------------------------------------- |
|
||||||
> | userId | `string` | UserId of current user | |
|
> | userId | `string` | UserId of current user | |
|
||||||
> | name | `string` | Monitor name | |
|
> | name | `string` | Monitor name | |
|
||||||
> | description | `string` | Monitor Description | |
|
> | description | `string` | Monitor Description | |
|
||||||
> | type | `string` | Valid email address | `"ping"`|`"http"` |
|
> | type | `string` | Valid email address | `"ping"`|`"http"`|`pagespeed` |
|
||||||
> | url | `string` | URL of service or IP | |
|
> | url | `string` | URL of service or IP | |
|
||||||
> | isActive | `boolean` | | |
|
> | isActive | `boolean` | | |
|
||||||
> | interval | `number` | In ms | |
|
> | interval | `number` | In ms | |
|
||||||
|
|
||||||
###### Response Payload
|
###### Response Payload
|
||||||
|
|
||||||
@@ -931,7 +939,6 @@ curl --request POST \
|
|||||||
--url http://localhost:5000/api/v1/monitors \
|
--url http://localhost:5000/api/v1/monitors \
|
||||||
--header <bearer_token> \
|
--header <bearer_token> \
|
||||||
--header 'Content-Type: application/json' \
|
--header 'Content-Type: application/json' \
|
||||||
--header 'User-Agent: insomnia/2023.5.8' \
|
|
||||||
--data '{
|
--data '{
|
||||||
"userId": "66675891cb17336d84c25d9f",
|
"userId": "66675891cb17336d84c25d9f",
|
||||||
"name": "Ping Google",
|
"name": "Ping Google",
|
||||||
@@ -970,9 +977,10 @@ curl --request POST \
|
|||||||
|
|
||||||
###### Method/Headers
|
###### Method/Headers
|
||||||
|
|
||||||
> | Method/Headers | Value |
|
> | Method/Headers | Value |
|
||||||
> | -------------- | ----- |
|
> | -------------- | ---------------- |
|
||||||
> | Method | POST |
|
> | Method | POST |
|
||||||
|
> | content-type | application/json |
|
||||||
|
|
||||||
###### Response Payload
|
###### Response Payload
|
||||||
|
|
||||||
@@ -1005,9 +1013,18 @@ curl --request POST \
|
|||||||
|
|
||||||
###### Method/Headers
|
###### Method/Headers
|
||||||
|
|
||||||
> | Method/Headers | Value |
|
> | Method/Headers | Value |
|
||||||
> | -------------- | ----- |
|
> | -------------- | ---------------- |
|
||||||
> | Method | POST |
|
> | Method | POST |
|
||||||
|
> | content-type | application/json |
|
||||||
|
|
||||||
|
##### Body
|
||||||
|
|
||||||
|
> | Name | Type | Notes | Accepted Values |
|
||||||
|
> | ----------- | -------- | ------------------- | --------------- |
|
||||||
|
> | name | `string` | Monitor name | |
|
||||||
|
> | description | `string` | Monitor Description | |
|
||||||
|
> | interval | `number` | In ms |
|
||||||
|
|
||||||
###### Response Payload
|
###### Response Payload
|
||||||
|
|
||||||
@@ -1024,12 +1041,8 @@ curl --request POST \
|
|||||||
--header 'Content-Type: application/json' \
|
--header 'Content-Type: application/json' \
|
||||||
--data '
|
--data '
|
||||||
{
|
{
|
||||||
"_id": "664e5ccf189c864800debc16",
|
|
||||||
"userId": "6645079aae0b439371913972",
|
|
||||||
"name": "Edited monitor",
|
"name": "Edited monitor",
|
||||||
"description": "Description",
|
"description": "Description",
|
||||||
"url": "https://monitor0.com",
|
|
||||||
"isActive": true,
|
|
||||||
"interval": 60000
|
"interval": 60000
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const {
|
|||||||
getMonitorByIdValidation,
|
getMonitorByIdValidation,
|
||||||
getMonitorsByUserIdValidation,
|
getMonitorsByUserIdValidation,
|
||||||
monitorValidation,
|
monitorValidation,
|
||||||
|
editMonitorBodyValidation,
|
||||||
} = require("../validation/joi");
|
} = require("../validation/joi");
|
||||||
|
|
||||||
const SERVICE_NAME = "monitorController";
|
const SERVICE_NAME = "monitorController";
|
||||||
@@ -251,7 +252,7 @@ const deleteAllMonitors = async (req, res) => {
|
|||||||
const editMonitor = async (req, res, next) => {
|
const editMonitor = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
await getMonitorByIdValidation.validateAsync(req.params);
|
await getMonitorByIdValidation.validateAsync(req.params);
|
||||||
await monitorValidation.validateAsync(req.body);
|
await editMonitorBodyValidation.validateAsync(req.body);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.status = 422;
|
error.status = 422;
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
|
|||||||
@@ -137,6 +137,12 @@ const monitorValidation = joi.object({
|
|||||||
interval: joi.number(),
|
interval: joi.number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const editMonitorBodyValidation = joi.object({
|
||||||
|
name: joi.string(),
|
||||||
|
description: joi.string(),
|
||||||
|
interval: joi.number(),
|
||||||
|
});
|
||||||
|
|
||||||
//****************************************
|
//****************************************
|
||||||
// Alerts
|
// Alerts
|
||||||
//****************************************
|
//****************************************
|
||||||
@@ -245,6 +251,7 @@ module.exports = {
|
|||||||
getMonitorByIdValidation,
|
getMonitorByIdValidation,
|
||||||
getMonitorsByUserIdValidation,
|
getMonitorsByUserIdValidation,
|
||||||
monitorValidation,
|
monitorValidation,
|
||||||
|
editMonitorBodyValidation,
|
||||||
editUserParamValidation,
|
editUserParamValidation,
|
||||||
editUserBodyValidation,
|
editUserBodyValidation,
|
||||||
createAlertParamValidation,
|
createAlertParamValidation,
|
||||||
|
|||||||
Reference in new issue
Block a user