mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-17 15:19:50 -06:00
270
README.md
270
README.md
@@ -302,38 +302,39 @@ Example:
|
||||
|
||||
##### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ---------------- |
|
||||
> | Method | POST |
|
||||
> | content-type | application/json |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ------------------- |
|
||||
> | Method | POST |
|
||||
> | content-type | multipart/form-data |
|
||||
|
||||
##### Body
|
||||
##### Form
|
||||
|
||||
> | Name | Type | Notes |
|
||||
> | --------- | -------- | ------------------- |
|
||||
> | firstname | `string` | |
|
||||
> | lastname | `string` |
|
||||
> | email | `string` | Valid email address |
|
||||
> | password | `string` | Min 8 chars |
|
||||
> | Name | Type | Notes |
|
||||
> | --------- | --------------- | ----------------------------------------------- |
|
||||
> | firstName | `string` | |
|
||||
> | lastName | `string` | |
|
||||
> | email | `string` | Valid email address |
|
||||
> | password | `string` | Min 8 chars, One Upper, one number, one special |
|
||||
> | role | `Array<string>` | Array of user roles |
|
||||
|
||||
##### Response Payload
|
||||
|
||||
> | Type | Notes |
|
||||
> | ---- | ---------------------------------- |
|
||||
> | JWT | JSON Web Token containing a `User` |
|
||||
> | Type | Notes |
|
||||
> | ---- | -------------- |
|
||||
> | User | User data |
|
||||
> | JWT | JSON web token |
|
||||
|
||||
##### Sample CURL request
|
||||
|
||||
```
|
||||
curl --request POST \
|
||||
--url http://localhost:5000/api/v1/auth/register \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"firstname" : "User First Name",
|
||||
"lastname": "User Last Name",
|
||||
"email" : "user@gmail.com",
|
||||
"password": "user_password"
|
||||
}'
|
||||
--header 'Content-Type: multipart/form-data' \
|
||||
--form firstName=Alex \
|
||||
--form lastName=Hollidaty \
|
||||
--form email=ajhollid@gmail.com \
|
||||
--form 'password=Testtest1!' \
|
||||
--form 'role[]=admin'
|
||||
```
|
||||
|
||||
##### Sample Response
|
||||
@@ -341,8 +342,22 @@ curl --request POST \
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"msg": "User created",
|
||||
"data": "<encoded_user>"
|
||||
"msg": "User created successfully",
|
||||
"data": {
|
||||
"user": {
|
||||
"_id": "66a1425b873da2207443f192",
|
||||
"firstName": "First Name",
|
||||
"lastName": "Last Name",
|
||||
"email": "name@gmail.com",
|
||||
"isActive": true,
|
||||
"isVerified": false,
|
||||
"role": ["admin"],
|
||||
"createdAt": "2024-07-24T18:05:15.852Z",
|
||||
"updatedAt": "2024-07-24T18:05:15.852Z",
|
||||
"__v": 0
|
||||
},
|
||||
"token": "<token>"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -363,23 +378,25 @@ curl --request POST \
|
||||
> | Name | Type | Notes |
|
||||
> | -------- | -------- | ------------------- |
|
||||
> | email | `string` | Valid email address |
|
||||
> | password | `string` | Min 8 chars |
|
||||
> | password | `string` | |
|
||||
|
||||
##### Response Payload
|
||||
|
||||
> | Type | Notes |
|
||||
> | ---- | ---------------------------------- |
|
||||
> | JWT | JSON Web Token Containing a `User` |
|
||||
> | Type | Notes |
|
||||
> | ---- | -------------- |
|
||||
> | User | User data |
|
||||
> | JWT | JSON web token |
|
||||
|
||||
##### Sample CURL request
|
||||
|
||||
```
|
||||
curl --request POST \
|
||||
--url http://localhost:5000/api/v1/auth/login \
|
||||
--header 'Authorization: Bearer undefined' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"email" : "user@gmail.com",
|
||||
"password": "user_password"
|
||||
"email" : "name@gmail.com",
|
||||
"password": "Testtest1!"
|
||||
}'
|
||||
```
|
||||
|
||||
@@ -387,9 +404,25 @@ curl --request POST \
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"msg": "Found user",
|
||||
"data": "<encoded_user>"
|
||||
{
|
||||
"success": true,
|
||||
"msg": "User logged in successfully",
|
||||
"data": {
|
||||
"user": {
|
||||
"_id": "66a1425b873da2207443f192",
|
||||
"firstName": "First Name",
|
||||
"lastName": "Last Name",
|
||||
"email": "name@gmail.com",
|
||||
"isActive": true,
|
||||
"isVerified": false,
|
||||
"role": ["admin"],
|
||||
"createdAt": "2024-07-24T18:05:15.852Z",
|
||||
"updatedAt": "2024-07-24T18:05:15.852Z",
|
||||
"__v": 0
|
||||
},
|
||||
"token": "<token>"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -400,18 +433,20 @@ curl --request POST \
|
||||
|
||||
###### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ----- |
|
||||
> | Method | POST |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ------------------- |
|
||||
> | Method | POST |
|
||||
> | content-type | multipart/form-data |
|
||||
|
||||
##### Body
|
||||
##### Form
|
||||
|
||||
> | Name | Type | Notes |
|
||||
> | ------------- | -------- | ----------- |
|
||||
> | firstname | `string` | |
|
||||
> | lastname | `string` | |
|
||||
> | profilePicUrl | `string` | |
|
||||
> | password | `string` | Min 8 chars |
|
||||
> | Name | Type | Notes |
|
||||
> | ----------- | -------- | --------------------------- |
|
||||
> | firstName | `string` | Optional |
|
||||
> | lastName | `string` | Optional |
|
||||
> | profileIame | `file` | Optional |
|
||||
> | password | `string` | Required to change password |
|
||||
> | newPassword | `string` | Required to change password |
|
||||
|
||||
###### Response Payload
|
||||
|
||||
@@ -423,13 +458,14 @@ curl --request POST \
|
||||
|
||||
```
|
||||
curl --request POST \
|
||||
--url http://localhost:5000/api/v1/auth/user/6654d156634754f789e1f10e \
|
||||
--url http://localhost:5000/api/v1/auth/user/66a1425b873da2207443f192 \
|
||||
--header 'Authorization: <bearer_token>' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"firstname": "First Name",
|
||||
"lastname: "Last Name"
|
||||
}'
|
||||
--header 'Content-Type: multipart/form-data' \
|
||||
--form firstName=Test \
|
||||
--form lastName=Test \
|
||||
--form profileImage=@/home/user/Desktop/cat.jpg \
|
||||
--form 'newPassword=Testtest1!' \
|
||||
--form 'password=Testtest2!'
|
||||
```
|
||||
|
||||
###### Sample Response
|
||||
@@ -437,17 +473,19 @@ curl --request POST \
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"msg": "User updated",
|
||||
"msg": "User updated successfully",
|
||||
"data": {
|
||||
"_id": "6654d156634754f789e1f10e",
|
||||
"firstname": "First Name",
|
||||
"lastname": "Last Name",
|
||||
"email": "me@gmail.com",
|
||||
"_id": "66a1425b873da2207443f192",
|
||||
"firstName": "First name",
|
||||
"lastName": "Last name",
|
||||
"email": "name@gmail.com",
|
||||
"isActive": true,
|
||||
"isVerified": false,
|
||||
"createdAt": "2024-05-27T18:30:46.358Z",
|
||||
"updatedAt": "2024-05-27T19:21:51.747Z",
|
||||
"__v": 0
|
||||
"role": ["admin"],
|
||||
"createdAt": "2024-07-24T18:05:15.852Z",
|
||||
"updatedAt": "2024-07-24T18:31:32.314Z",
|
||||
"__v": 0,
|
||||
"avatarImage": "<Base64 Image>"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -459,9 +497,10 @@ curl --request POST \
|
||||
|
||||
###### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ----- |
|
||||
> | Method | GET |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ---------------- |
|
||||
> | Method | GET |
|
||||
> | content-type | application/json |
|
||||
|
||||
###### Response Payload
|
||||
|
||||
@@ -475,7 +514,6 @@ curl --request POST \
|
||||
curl --request GET \
|
||||
--url http://localhost:5000/api/v1/auth/users \
|
||||
--header 'Authorization: <bearer_token>\
|
||||
--header 'User-Agent: insomnia/2023.5.8'
|
||||
```
|
||||
|
||||
##### Sample Resonse
|
||||
@@ -487,9 +525,9 @@ curl --request GET \
|
||||
"data": [
|
||||
{
|
||||
"_id": "669e90072d5663d25808bc7b",
|
||||
"firstName": "Alex",
|
||||
"lastName": "Holliday",
|
||||
"email": "test@test.com",
|
||||
"firstName": "First name",
|
||||
"lastName": "Last name",
|
||||
"email": "name@gmail.com",
|
||||
"isActive": true,
|
||||
"isVerified": false,
|
||||
"role": ["admin"],
|
||||
@@ -508,9 +546,10 @@ curl --request GET \
|
||||
|
||||
###### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ----- |
|
||||
> | Method | POST |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ---------------- |
|
||||
> | Method | POST |
|
||||
> | content-type | application/json |
|
||||
|
||||
##### Body
|
||||
|
||||
@@ -531,7 +570,7 @@ curl --request POST \
|
||||
--url http://localhost:5000/api/v1/auth/recovery/request \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"email" : "ajhollid@gmail.com"
|
||||
"email" : "name@gmail.com"
|
||||
}'
|
||||
```
|
||||
|
||||
@@ -542,7 +581,7 @@ curl --request POST \
|
||||
"success": true,
|
||||
"msg": "Created recovery token",
|
||||
"data": {
|
||||
"email": "your_email@gmail.com",
|
||||
"email": "name@gmail.com",
|
||||
"token": "f519da5e4a9be40cfc3c0fde97e60c0e6d17bdaa613f5ba537a45073f3865193",
|
||||
"_id": "6668878263587f30748e968e",
|
||||
"expiry": "2024-06-11T17:21:06.984Z",
|
||||
@@ -560,9 +599,10 @@ curl --request POST \
|
||||
|
||||
###### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ----- |
|
||||
> | Method | POST |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ---------------- |
|
||||
> | Method | POST |
|
||||
> | content-type | application/json |
|
||||
|
||||
##### Body
|
||||
|
||||
@@ -595,7 +635,7 @@ curl --request POST \
|
||||
"msg": "Token is valid",
|
||||
"data": {
|
||||
"_id": "6668894263587f30748e969a",
|
||||
"email": "ajhollid@gmail.com",
|
||||
"email": "name@gmail.com",
|
||||
"token": "457d9926b24dedf613f120eeb524ef00ac45b3f0fc5c70bd25b1cc8aa83a64a0",
|
||||
"expiry": "2024-06-11T17:28:34.349Z",
|
||||
"createdAt": "2024-06-11T17:28:34.349Z",
|
||||
@@ -612,9 +652,10 @@ curl --request POST \
|
||||
|
||||
###### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ----- |
|
||||
> | Method | POST |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ---------------- |
|
||||
> | Method | POST |
|
||||
> | content-type | application/json |
|
||||
|
||||
##### Body
|
||||
|
||||
@@ -649,9 +690,9 @@ curl --request POST \
|
||||
"msg": "Password reset",
|
||||
"data": {
|
||||
"_id": "66675891cb17336d84c25d9f",
|
||||
"firstname": "User First Name",
|
||||
"lastname": "User Last Name",
|
||||
"email": "your_email@gmail.com",
|
||||
"firstname": "First Name",
|
||||
"lastname": "Last Name",
|
||||
"email": "name@gmail.com",
|
||||
"isActive": true,
|
||||
"isVerified": false,
|
||||
"createdAt": "2024-06-10T19:48:33.863Z",
|
||||
@@ -672,9 +713,10 @@ curl --request POST \
|
||||
|
||||
##### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ----- |
|
||||
> | Method | GET |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ---------------- |
|
||||
> | Method | GET |
|
||||
> | content-type | application/json |
|
||||
|
||||
##### Response Payload
|
||||
|
||||
@@ -732,9 +774,10 @@ curl --request GET \
|
||||
|
||||
###### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ----- |
|
||||
> | Method | GET |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ---------------- |
|
||||
> | Method | GET |
|
||||
> | content-type | application/json |
|
||||
|
||||
###### Response Payload
|
||||
|
||||
@@ -803,9 +846,10 @@ curl --request GET \
|
||||
|
||||
###### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ----- |
|
||||
> | Method | GET |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ---------------- |
|
||||
> | Method | GET |
|
||||
> | content-type | application/json |
|
||||
|
||||
###### Response Payload
|
||||
|
||||
@@ -865,21 +909,22 @@ curl --request GET \
|
||||
|
||||
###### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ----- |
|
||||
> | Method | POST |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ---------------- |
|
||||
> | Method | POST |
|
||||
> | content-type | application/json |
|
||||
|
||||
##### Body
|
||||
|
||||
> | Name | Type | Notes | Accepted Values |
|
||||
> | ----------- | --------- | ---------------------- | ---------------------- |
|
||||
> | userId | `string` | UserId of current user | |
|
||||
> | name | `string` | Monitor name | |
|
||||
> | description | `string` | Monitor Description | |
|
||||
> | type | `string` | Valid email address | `"ping"`|`"http"` |
|
||||
> | url | `string` | URL of service or IP | |
|
||||
> | isActive | `boolean` | | |
|
||||
> | interval | `number` | In ms | |
|
||||
> | Name | Type | Notes | Accepted Values |
|
||||
> | ----------- | --------- | ---------------------- | --------------------------------------- |
|
||||
> | userId | `string` | UserId of current user | |
|
||||
> | name | `string` | Monitor name | |
|
||||
> | description | `string` | Monitor Description | |
|
||||
> | type | `string` | Valid email address | `"ping"`|`"http"`|`pagespeed` |
|
||||
> | url | `string` | URL of service or IP | |
|
||||
> | isActive | `boolean` | | |
|
||||
> | interval | `number` | In ms | |
|
||||
|
||||
###### Response Payload
|
||||
|
||||
@@ -894,7 +939,6 @@ curl --request POST \
|
||||
--url http://localhost:5000/api/v1/monitors \
|
||||
--header <bearer_token> \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'User-Agent: insomnia/2023.5.8' \
|
||||
--data '{
|
||||
"userId": "66675891cb17336d84c25d9f",
|
||||
"name": "Ping Google",
|
||||
@@ -933,9 +977,10 @@ curl --request POST \
|
||||
|
||||
###### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ----- |
|
||||
> | Method | POST |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ---------------- |
|
||||
> | Method | POST |
|
||||
> | content-type | application/json |
|
||||
|
||||
###### Response Payload
|
||||
|
||||
@@ -968,9 +1013,18 @@ curl --request POST \
|
||||
|
||||
###### Method/Headers
|
||||
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ----- |
|
||||
> | Method | POST |
|
||||
> | Method/Headers | Value |
|
||||
> | -------------- | ---------------- |
|
||||
> | 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
|
||||
|
||||
@@ -987,12 +1041,8 @@ curl --request POST \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '
|
||||
{
|
||||
"_id": "664e5ccf189c864800debc16",
|
||||
"userId": "6645079aae0b439371913972",
|
||||
"name": "Edited monitor",
|
||||
"description": "Description",
|
||||
"url": "https://monitor0.com",
|
||||
"isActive": true,
|
||||
"interval": 60000
|
||||
}'
|
||||
```
|
||||
|
||||
@@ -2,6 +2,7 @@ const {
|
||||
getMonitorByIdValidation,
|
||||
getMonitorsByUserIdValidation,
|
||||
monitorValidation,
|
||||
editMonitorBodyValidation,
|
||||
} = require("../validation/joi");
|
||||
|
||||
const SERVICE_NAME = "monitorController";
|
||||
@@ -251,7 +252,7 @@ const deleteAllMonitors = async (req, res) => {
|
||||
const editMonitor = async (req, res, next) => {
|
||||
try {
|
||||
await getMonitorByIdValidation.validateAsync(req.params);
|
||||
await monitorValidation.validateAsync(req.body);
|
||||
await editMonitorBodyValidation.validateAsync(req.body);
|
||||
} catch (error) {
|
||||
error.status = 422;
|
||||
error.service = SERVICE_NAME;
|
||||
|
||||
@@ -137,6 +137,12 @@ const monitorValidation = joi.object({
|
||||
interval: joi.number(),
|
||||
});
|
||||
|
||||
const editMonitorBodyValidation = joi.object({
|
||||
name: joi.string(),
|
||||
description: joi.string(),
|
||||
interval: joi.number(),
|
||||
});
|
||||
|
||||
//****************************************
|
||||
// Alerts
|
||||
//****************************************
|
||||
@@ -245,6 +251,7 @@ module.exports = {
|
||||
getMonitorByIdValidation,
|
||||
getMonitorsByUserIdValidation,
|
||||
monitorValidation,
|
||||
editMonitorBodyValidation,
|
||||
editUserParamValidation,
|
||||
editUserBodyValidation,
|
||||
createAlertParamValidation,
|
||||
|
||||
Reference in New Issue
Block a user