2024-06-07 13:38:32 -07:00







![]()
2024-05-10 02:45:41 -04:00
# BlueWave Uptime
2024-05-05 11:09:19 -07:00
2024-05-02 11:47:47 -04:00
BlueWave uptime monitoring application
2024-05-05 11:09:19 -07:00
## Getting Started
- Clone this repository to your local machine
2024-05-15 12:40:56 -07:00
1. [Installation (Client) ](#client )
2024-06-12 11:25:51 -07:00
2. [Configuration(Client) ](#config-client )
2024-06-12 11:04:11 -07:00
- [Environment ](#env-vars-client )
2024-06-14 12:07:34 -07:00
3. [Getting Started (Server) ](#server )
- [Docker Compose Quickstart ](#docker-quickstart )
- [Manual Installation ](#manual-install )
- [Install Server ](#install-server )
- [Environment ](#env-vars-server )
- [Database ](#databases )
- [(Optional) Dockerised Databases ](#optional-docker-databases )
- [Start Server ](#start-server )
4. [Endpoints ](#endpoints )
2024-05-27 16:04:44 -07:00
###### Auth
2024-05-25 20:14:06 -07:00
- <code>POST</code> [/api/v1/auth/register ](#post-register )
- <code>POST</code> [/api/v1/auth/login ](#post-login )
2024-05-27 12:27:57 -07:00
- <code>POST</code> [/api/v1/auth/user/{userId} ](#post-auth-user-edit-id )
2024-06-11 10:36:56 -07:00
- <code>POST</code> [/api/v1/auth/recovery/request ](#post-auth-recovery-request-id )
- <code>POST</code> [/api/v1/auth/recovery/validate ](#post-auth-recovery-validate-id )
- <code>POST</code> [/api/v1/auth/recovery/reset ](#post-auth-recovery-reset-id )
2024-05-27 16:04:44 -07:00
###### Monitors
2024-05-25 20:14:06 -07:00
- <code>GET</code> [/api/v1/monitors ](#get-monitors )
- <code>GET</code> [/api/v1/monitor/{id} ](#get-monitor-id )
- <code>GET</code> [/api/v1/monitors/user/{userId} ](#get-monitors-user-userid )
- <code>POST</code> [/api/v1/monitors ](#post-monitors )
- <code>POST</code> [/api/v1/monitors/delete/{monitorId} ](#post-monitors-del-id )
- <code>POST</code> [/api/v1/monitors/edit/{monitorId} ](#post-monitors-edit-id )
2024-05-27 16:04:44 -07:00
###### Checks
- <code>POST</code> [/api/v1/checks/{monitorId} ](#post-checks )
- <code>GET</code> [/api/v1/checks/{monitorId} ](#get-checks )
- <code>POST</code> [/api/v1/checks/delete/{monitorId} ](#delete-checks )
2024-05-28 13:18:32 -07:00
###### Alerts
- <code>POST</code> [/api/v1/alerts/{monitorId} ](#create-alert )
- <code>GET</code> [/api/v1/alerts/user/{userId} ](#get-alerts-user-id )
- <code>GET</code> [/api/v1/alerts/monitor/{monitorId} ](#get-alerts-monitor-id )
- <code>GET</code> [/api/v1/alerts/{alertId} ](#get-alert-alert-id )
- <code>POST</code> [/api/v1/alerts/edit/{alertId} ](#edit-alert )
- <code>POST</code> [/api/v1/alerts/delete/{alertId} ](#delete-alert )
2024-06-14 12:07:34 -07:00
5. [Error Handling ](#error-handling )
6. [Contributors ](#contributors )
2024-05-15 12:40:56 -07:00
2024-05-05 11:09:19 -07:00
---
### Client
2024-06-12 11:25:51 -07:00
#### <u>Installation</u>
2024-05-05 11:09:19 -07:00
1. Change directory to the `Client` directory
2. Install all dependencies by running `npm install`
2024-06-12 11:04:11 -07:00
<br/>
2024-06-12 11:25:51 -07:00
#### <u>Configuration</u> <a id="config-client"></a>
2024-06-12 11:04:11 -07:00
##### Environmental Variables <a id="env-vars-client"></a>
| ENV Variable Name | Required/Optional | Type | Description | Accepted Values |
| --------------------- | ----------------- | -------- | ------------------ | --------------- |
| VITE_APP_API_BASE_URL | Required | `string` | Base URL of server | {host}/api/v1 |
<br/>
2024-06-12 11:25:51 -07:00
#### <u>Starting Development Server</u>
2024-05-05 11:09:19 -07:00
1. Run `npm run dev` to start the development server.
---
2024-06-14 12:07:34 -07:00
### Getting Started (Server)
2024-05-05 11:09:19 -07:00
2024-06-14 12:07:34 -07:00
#### <u>Docker Quickstart</u> <a id="docker-quickstart"></a>
The fastest way to start the server is to use our Dockerfiles and [Docker Compose ](https://docs.docker.com/compose/ ).
To get the server up and running you need to:
1. In the `Server/docker` directory run the build script `build_images.sh` to build docker images for the server, Redis database, and MongoDB database.
2. In the `Server/docker` directory, create a `.env` file with the [requried environtmental variables ](#env-vars-server ). Sample file:
```
CLIENT_HOST="http://localhost:5173"
JWT_SECRET="my_secret"
DB_TYPE="MongoDB"
DB_CONNECTION_STRING="mongodb://mongodb:27017/uptime_db"
REDIS_HOST="redis"
REDIS_PORT=6379
SYSTEM_EMAIL_ADDRESS="<email>"
SENDGRID_API_KEY="<api_key>"
LOGIN_PAGE_URL="<login_page"
```
3. In the `Server/docker` directory run `docker compose up` to run the `docker-compose.yaml` file and start all three images.
That's it, the server is ready to use.
<br/>
#### <u>Manual Install</u> <a id="manual-install"></a>
##### Install Server <a id="install-server"></a>
2024-05-05 11:09:19 -07:00
1. Change directory to the `Server` directory
2024-05-22 14:38:47 -07:00
2. Install all dependencies by running `npm install`
2024-05-05 11:09:19 -07:00
2024-06-12 11:04:11 -07:00
<br/>
2024-05-10 14:34:04 -07:00
2024-06-12 11:04:11 -07:00
##### Environmental Variables <a id="env-vars-server"></a>
2024-05-28 10:41:10 -07:00
Configure the server with the following environmental variables:
2024-05-10 14:34:04 -07:00
2024-06-05 14:17:54 -04:00
| ENV Variable Name | Required/Optional | Type | Description | Accepted Values |
| -------------------- | ----------------- | --------- | ------------------------------------------------------------------------------------------- | ------------------- |
2024-06-11 11:41:57 -07:00
| CLIENT_HOST | Required | `string` | Frontend Host | |
2024-06-05 14:17:54 -04:00
| JWT_SECRET | Required | `string` | JWT secret | |
| DB_TYPE | Optional | `string` | Specify DB to use | `MongoDB \| FakeDB` |
| DB_CONNECTION_STRING | Required | `string` | Specifies URL for MongoDB Database | |
| PORT | Optional | `integer` | Specifies Port for Server | |
| SENDGRID_API_KEY | Required | `string` | Specifies API KEY for SendGrid email service | |
| SYSTEM_EMAIL_ADDRESS | Required | `string` | Specifies System email to be used in emailing service, must be a verified email by sendgrid | |
2024-06-05 18:30:23 -04:00
| LOGIN_PAGE_URL | Required | `string` | Login url to be used in emailing service | |
2024-06-05 12:34:59 -07:00
| REDIS_HOST | Required | `string` | Host address for Redis database | |
| REDIS_PORT | Required | `integer` | Port for Redis database | |
2024-05-10 14:34:04 -07:00
2024-06-12 11:04:11 -07:00
<br/>
2024-05-10 14:34:04 -07:00
2024-06-14 12:07:34 -07:00
##### Databases <a id="databases"></a>
2024-05-28 10:41:10 -07:00
This project requires a number of databases to run:
1. Main database for the application. This project includes an implementation for a MongoDB database as well as a MongoDB Docker image.
2. A Redis database is required for the Queue implementation in the PingService. This project includes a Redis docker image.
2024-06-14 12:07:34 -07:00
You may use the included Dockerfiles to spin up databases quickly if you wish.
2024-05-28 10:41:10 -07:00
2024-06-14 12:07:34 -07:00
###### (Optional) Dockerised Databases <a id="optional-docker-databases"></a>
2024-05-28 10:41:10 -07:00
2024-06-14 12:07:34 -07:00
Dockerfiles for the server and databases are located in the `./Server/docker` directory
2024-05-28 10:41:10 -07:00
<details>
<summary><b>MongoDB Image</b></summary>
2024-06-14 12:07:34 -07:00
Location: `./Server/docker/mongoDB.Dockerfile`
2024-05-28 10:41:10 -07:00
2024-06-14 12:07:34 -07:00
The `./Server/docker/mongo/data` directory should be mounted to the MongoDB container in order to persist data.
2024-05-28 10:41:10 -07:00
2024-06-14 12:07:34 -07:00
From the `Server/docker` directory run
2024-05-28 10:41:10 -07:00
2024-06-14 12:07:34 -07:00
1. Build the image: `docker build -f mongoDB.Dockerfile -t uptime_database_mongo .`
2. Run the docker image: `docker run -d -p 27017:27017 -v $(pwd)/mongo/data:/data/db --name uptime_database_mongo uptime_database_mongo`
2024-05-28 10:41:10 -07:00
</details>
<details>
<summary><b>Redis Image</b></summary>
2024-06-14 12:07:34 -07:00
Location `./Server/docker/redislDockerfile`
2024-05-28 10:41:10 -07:00
2024-06-14 12:07:34 -07:00
the `./Server/docker/redis/data` directory should be mounted to the Redis container in order to persist data.
2024-05-28 10:41:10 -07:00
2024-06-14 12:07:34 -07:00
From the `Server/docker` directory run
2024-05-28 10:41:10 -07:00
2024-06-14 12:07:34 -07:00
1. Build the image: `docker build -f redis.Dockerfile -t uptime_redis .`
2. Run the image: `docker run -d -p 6379:6379 -v $(pwd)/redis/data:/data --name uptime_redis uptime_redis`
2024-05-28 10:41:10 -07:00
</details>
2024-06-12 11:04:11 -07:00
<br/>
2024-05-28 10:41:10 -07:00
2024-06-14 12:07:34 -07:00
##### Starting the Development Server <a id="start-server"></a>
- run `npm run dev` to start the development server
OR
2024-05-05 11:09:19 -07:00
2024-06-14 12:07:34 -07:00
- run `node index.js` to start server
2024-05-10 02:16:50 -04:00
2024-05-10 14:34:04 -07:00
---
#### Endpoints
All endpoints return a response in this format:
| Name | Type | Notes |
| ------- | --------- | ----------------------------- |
| success | `boolean` | Success or failure of request |
| msg | `string` | Message describing response |
| data | `Object` | Arbitrary Payload |
Example:
```
{success: true, msg: "Successful Request", data: {test: testData}}
```
2024-05-15 12:16:04 -07:00
---
2024-05-10 14:34:04 -07:00
##### Data Types
2024-05-15 12:16:04 -07:00
<details>
<summary><code>User</code></summary>
| Name | Type | Notes |
| ------------- | --------- | --------------------- |
| firstname | `string` | First name |
| lastname | `string` | Last name |
| email | `string` | User's email |
| profilePicUrl | `string` | URL to User's picture |
| isActive | `boolean` | Default to `true` |
| isVerified | `boolean` | Default to `false` |
| updated_at | `Date` | Last update time |
| created_at | `Date` | Time created at |
</details>
<details>
<summary><code>Monitor</code></summary>
2024-05-10 14:34:04 -07:00
| Name | Type | Notes |
| ----------- | --------- | ---------------------------------------- |
| userId | `string` | Unique ID identifying monitor creator |
| name | `string` | Name of the monitor |
| description | `string` | Description of the monitor |
| url | `string` | Url the monitor will ping |
| isActive | `boolean` | Whether or not the monitor is active |
| interval | `integer` | Interval with which to ping monitor (ms) |
| updatedAt | `Date` | Last time the monitor was updated |
| CreatedAt | `Date` | When the monitor was updated |
2024-05-15 12:16:04 -07:00
</details>
2024-05-27 15:07:34 -04:00
<details>
<summary><code>Check</code></summary>
2024-05-28 10:41:10 -07:00
| 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 |
2024-05-27 15:07:34 -04:00
</details>
<details>
<summary><code>Alert</code></summary>
| Name | Type | Notes |
2024-05-28 10:41:10 -07:00
| ----------------- | --------- | ------------------------------------------------- |
2024-05-28 14:42:51 -04:00
| checkId | `string` | Unique ID for the associated check |
| monitorId | `string` | Unique ID for the associated monitor |
| userId | `string` | Unique ID for the associated user |
2024-05-28 10:41:10 -07:00
| status | `boolean` | Indicates the service is Up or Down |
2024-05-27 15:07:34 -04:00
| 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>
2024-05-27 16:04:44 -07:00
2024-05-15 12:16:04 -07:00
---
2024-05-27 16:04:44 -07:00
###### Auth
2024-05-15 12:16:04 -07:00
<details>
2024-05-25 13:56:19 -05:00
<summary id='post-register'><code>POST</code> <b>/api/v1/auth/register</b></summary>
2024-05-15 12:16:04 -07:00
##### Method/Headers
> | Method/Headers | Value |
> | -------------- | ---------------- |
> | Method | POST |
> | content-type | application/json |
##### Body
> | Name | Type | Notes |
> | --------- | -------- | ------------------- |
> | firstname | `string` | |
> | lastname | `string` |
> | email | `string` | Valid email address |
> | password | `string` | Min 8 chars |
##### Response Payload
2024-05-22 10:48:58 -07:00
> | Type | Notes |
> | ---- | ---------------------------------- |
> | JWT | JSON Web Token containing a `User` |
2024-05-15 12:16:04 -07:00
##### 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"
}'
```
##### Sample Response
```json
{
"success" : true ,
2024-05-22 14:38:47 -07:00
"msg" : "User created" ,
"data" : "<encoded_user>"
2024-05-15 12:16:04 -07:00
}
```
</details>
<details>
2024-05-25 13:56:19 -05:00
<summary id='post-login'><code>POST</code> <b>/api/v1/auth/login</b></summary>
2024-05-15 12:16:04 -07:00
##### Method/Headers
> | Method/Headers | Value |
> | -------------- | ---------------- |
> | Method | POST |
> | content-type | application/json |
2024-05-10 14:34:04 -07:00
2024-05-15 12:16:04 -07:00
##### Body
2024-05-10 14:34:04 -07:00
2024-05-15 12:16:04 -07:00
> | Name | Type | Notes |
> | -------- | -------- | ------------------- |
> | email | `string` | Valid email address |
> | password | `string` | Min 8 chars |
2024-05-10 14:34:04 -07:00
2024-05-15 12:16:04 -07:00
##### Response Payload
2024-05-10 14:34:04 -07:00
2024-05-22 10:48:58 -07:00
> | Type | Notes |
> | ---- | ---------------------------------- |
> | JWT | JSON Web Token Containing a `User` |
2024-05-15 12:16:04 -07:00
##### Sample CURL request
```
curl --request POST \
--url http://localhost:5000/api/v1/auth/login \
--header 'Content-Type: application/json' \
--data '{
"email" : "user@gmail.com",
"password": "user_password"
}'
```
##### Sample response
```json
{
"success" : true ,
"msg" : "Found user" ,
2024-05-22 14:38:47 -07:00
"data" : "<encoded_user>"
2024-05-15 12:16:04 -07:00
}
```
</details>
2024-05-10 14:34:04 -07:00
2024-05-27 12:27:57 -07:00
<details>
<summary id='post-auth-user-edit-id'><code>POST</code><b>/api/v1/auth/user/{userId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
##### Body
> | Name | Type | Notes |
> | ------------- | -------- | ----------- |
> | firstname | `string` | |
> | lastname | `string` | |
> | profilePicUrl | `string` | |
> | password | `string` | Min 8 chars |
###### Response Payload
> | Type | Notes |
> | ------ | ------------------------ |
> | `User` | Returns the updated user |
##### Sample CURL request
```
curl --request POST \
--url http://localhost:5000/api/v1/auth/user/6654d156634754f789e1f10e \
--header 'Authorization: <bearer_token>' \
--header 'Content-Type: application/json' \
--data '{
"firstname": "First Name",
"lastname: "Last Name"
}'
```
###### Sample Response
```json
{
"success" : true ,
"msg" : "User updated" ,
"data" : {
"_id" : "6654d156634754f789e1f10e" ,
"firstname" : "First Name" ,
"lastname" : "Last Name" ,
"email" : "me@gmail.com" ,
"isActive" : true ,
"isVerified" : false ,
"createdAt" : "2024-05-27T18:30:46.358Z" ,
"updatedAt" : "2024-05-27T19:21:51.747Z" ,
"__v" : 0
}
}
```
</details>
2024-06-11 10:36:56 -07:00
<details>
<summary id='post-auth-recovery-request-id'><code>POST</code><b>/api/v1/auth/recovery/request</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
##### Body
> | Name | Type | Notes |
> | ----- | -------- | ------------ |
> | email | `string` | User's email |
###### Response Payload
> | Type | Notes |
> | --------------- | --------------------------------------- |
> | `RecoveryToken` | Returns a recovery token if email found |
##### Sample CURL request
```
curl --request POST \
--url http://localhost:5000/api/v1/auth/recovery/request \
--header 'Content-Type: application/json' \
--data '{
"email" : "ajhollid@gmail.com"
}'
```
###### Sample Response
```json
{
"success" : true ,
"msg" : "Created recovery token" ,
"data" : {
"email" : "your_email@gmail.com" ,
"token" : "f519da5e4a9be40cfc3c0fde97e60c0e6d17bdaa613f5ba537a45073f3865193" ,
"_id" : "6668878263587f30748e968e" ,
"expiry" : "2024-06-11T17:21:06.984Z" ,
"createdAt" : "2024-06-11T17:21:06.985Z" ,
"updatedAt" : "2024-06-11T17:21:06.985Z" ,
"__v" : 0
}
}
```
</details>
<details>
<summary id='post-auth-recovery-validate-id'><code>POST</code><b>/api/v1/auth/recovery/validate</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
##### Body
> | Name | Type | Notes |
> | ------------- | -------- | ----------------------------------- |
> | recoveryToken | `string` | Token issued in `/recovery/request` |
###### Response Payload
> | Type | Notes |
> | --------------- | -------------------------- |
> | `RecoveryToken` | Returns the recovery token |
##### Sample CURL request
```
curl --request POST \
--url http://localhost:5000/api/v1/auth/recovery/validate \
--header 'Content-Type: application/json' \
--data '{
"recoveryToken" : "f519da5e4a9be40cfc3c0fde97e60c0e6d17bdaa613f5ba537a45073f3865193"
}'
```
###### Sample Response
```json
{
"success" : true ,
"msg" : "Token is valid" ,
"data" : {
"_id" : "6668894263587f30748e969a" ,
"email" : "ajhollid@gmail.com" ,
"token" : "457d9926b24dedf613f120eeb524ef00ac45b3f0fc5c70bd25b1cc8aa83a64a0" ,
"expiry" : "2024-06-11T17:28:34.349Z" ,
"createdAt" : "2024-06-11T17:28:34.349Z" ,
"updatedAt" : "2024-06-11T17:28:34.349Z" ,
"__v" : 0
}
}
```
</details>
<details>
<summary id='post-auth-recovery-reset-id'><code>POST</code><b>/api/v1/auth/recovery/reset</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
##### Body
> | Name | Type | Notes |
> | ------------- | -------- | --------------------------------------------- |
> | recoveryToken | `string` | Token issued returned by `/recovery/validate` |
> | password | `string` | User's new password` |
###### Response Payload
> | Type | Notes |
> | ------ | ------------------------ |
> | `User` | Returns the updated user |
##### Sample CURL request
```
curl --request POST \
--url http://localhost:5000/api/v1/auth/recovery/reset \
--header 'Content-Type: application/json' \
--data '{
"recoveryToken" : "f519da5e4a9be40cfc3c0fde97e60c0e6d17bdaa613f5ba537a45073f3865193",
"password": "testtest"
}'
```
###### Sample Response
```json
{
"success" : true ,
"msg" : "Password reset" ,
"data" : {
"_id" : "66675891cb17336d84c25d9f" ,
"firstname" : "User First Name" ,
"lastname" : "User Last Name" ,
"email" : "your_email@gmail.com" ,
"isActive" : true ,
"isVerified" : false ,
"createdAt" : "2024-06-10T19:48:33.863Z" ,
"updatedAt" : "2024-06-11T17:21:22.289Z" ,
"__v" : 0
}
}
```
</details>
2024-05-27 12:27:57 -07:00
---
2024-05-27 16:04:44 -07:00
###### Monitors
2024-05-15 12:16:04 -07:00
<details>
2024-05-25 13:56:19 -05:00
<summary id='get-monitors'><code>GET</code> <b>/api/v1/monitors</b></summary>
2024-05-15 12:16:04 -07:00
##### Method/Headers
2024-05-10 14:34:04 -07:00
2024-05-15 12:16:04 -07:00
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
2024-05-10 14:34:04 -07:00
2024-05-15 12:16:04 -07:00
##### Response Payload
2024-05-10 14:34:04 -07:00
2024-05-28 13:18:32 -07:00
> | Type | Notes |
> | ---------------- | --------------------- |
> | `Array<Monitor>` | Array of all monitors |
2024-05-10 14:34:04 -07:00
2024-05-22 14:38:47 -07:00
###### Sample cURL Request
```
curl --request GET \
--url http://localhost:5000/api/v1/monitors \
--header '<bearer_token>' \
```
###### Sample Response
```json
{
"success" : true ,
"msg" : "Monitors found" ,
"data" : [
{
"_id" : "664d070786e62625ac612ca1" ,
"userId" : "6645079aae0b439371913972" ,
"name" : "Wha3" ,
"description" : "Description" ,
"url" : "https://monitor0.com" ,
"isActive" : true ,
"interval" : 60000 ,
"createdAt" : "2024-05-21T20:41:43.051Z" ,
"updatedAt" : "2024-05-21T20:45:10.496Z" ,
"__v" : 0
},
{
"_id" : "664e5ccf189c864800debc16" ,
"userId" : "6645079aae0b439371913972" ,
"name" : "Inserting a new Monitor" ,
"description" : "Description" ,
"url" : "https://monitor0.com" ,
"isActive" : true ,
"interval" : 60000 ,
"createdAt" : "2024-05-22T20:59:59.295Z" ,
"updatedAt" : "2024-05-22T20:59:59.295Z" ,
"__v" : 0
}
]
}
```
2024-05-15 12:16:04 -07:00
</details>
2024-05-10 14:34:04 -07:00
2024-05-15 12:16:04 -07:00
<details>
2024-05-25 13:56:19 -05:00
<summary id='get-monitor-id'><code>GET</code> <b>/api/v1/monitor/{id}</b></summary>
2024-05-15 12:16:04 -07:00
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
###### Response Payload
> | Type | Notes |
> | --------- | --------------------------------------------------- |
> | `Monitor` | Single monitor with the id in the request parameter |
2024-05-22 14:38:47 -07:00
###### Sample cURL Request
```
curl --request GET \
--url http://localhost:5000/api/v1/monitors/664d070786e62625ac612ca1 \
--header '<bearer_token>' \
```
###### Sample Response
```json
{
"success" : true ,
"msg" : "Monitor found" ,
"data" : {
"_id" : "664d070786e62625ac612ca1" ,
"userId" : "6645079aae0b439371913972" ,
"name" : "My Monitor" ,
"description" : "Description" ,
"url" : "https://monitor0.com" ,
"isActive" : true ,
"interval" : 60000 ,
"createdAt" : "2024-05-21T20:41:43.051Z" ,
"updatedAt" : "2024-05-21T20:45:10.496Z" ,
"__v" : 0
}
}
```
2024-05-15 12:16:04 -07:00
</details>
<details>
2024-05-25 13:56:19 -05:00
<summary id='get-monitors-user-userid'><code>GET</code> <b>/api/v1/monitors/user/{userId}</b></summary>
2024-05-15 12:16:04 -07:00
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
2024-05-10 14:34:04 -07:00
2024-05-22 14:38:47 -07:00
###### Response Payload
2024-05-10 14:34:04 -07:00
2024-05-28 13:18:32 -07:00
> | Type | Notes |
> | ---------------- | ------------------------------------------------------- |
> | `Array<Monitor>` | Array of monitors created by user with specified UserID |
2024-05-10 14:34:04 -07:00
2024-05-22 14:38:47 -07:00
###### Sample cURL Request
```
curl --request GET \
--url http://localhost:5000/api/v1/monitors/user/6645079aae0b439371913972 \
--header '<bearer_token>' \
```
###### Sample Response
```json
{
"success" : true ,
"msg" : "Monitors for user 6645079aae0b439371913972 found" ,
"data" : [
{
"_id" : "664d070786e62625ac612ca1" ,
"userId" : "6645079aae0b439371913972" ,
"name" : "Wha3" ,
"description" : "Description" ,
"url" : "https://monitor0.com" ,
"isActive" : true ,
"interval" : 60000 ,
"createdAt" : "2024-05-21T20:41:43.051Z" ,
"updatedAt" : "2024-05-21T20:45:10.496Z" ,
"__v" : 0
},
{
"_id" : "664e5ccf189c864800debc16" ,
"userId" : "6645079aae0b439371913972" ,
"name" : "Inserting a new Monitor" ,
"description" : "Description" ,
"url" : "https://monitor0.com" ,
"isActive" : true ,
"interval" : 60000 ,
"createdAt" : "2024-05-22T20:59:59.295Z" ,
"updatedAt" : "2024-05-22T20:59:59.295Z" ,
"__v" : 0
}
]
}
```
</details>
<details>
2024-05-25 13:56:19 -05:00
<summary id='post-monitors'><code>POST</code><b>/api/v1/monitors</b></summary>
2024-05-22 14:38:47 -07:00
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
2024-05-28 13:18:32 -07:00
> | Type | Notes |
> | --------- | ------------------------------- |
> | `Monitor` | Returns newly created `Monitor` |
2024-05-22 14:38:47 -07:00
##### Sample CURL request
```
curl --request POST \
--url http://localhost:5000/api/v1/monitors \
--header <bearer_token> \
--header 'Content-Type: application/json' \
--data '{"userId": "6645079aae0b439371913972",
"name": "Inserting a new Monitor",
"description": "Description",
"url": "https://monitor0.com",
"isActive": true,
"interval": 60000}'
```
##### Sample Response
```json
{
"success" : true ,
"msg" : "Monitor created" ,
"data" : {
"userId" : "6645079aae0b439371913972" ,
"name" : "Inserting a new Monitor" ,
"description" : "Description" ,
"url" : "https://monitor0.com" ,
"isActive" : true ,
"interval" : 60000 ,
"_id" : "664e5ccf189c864800debc16" ,
"createdAt" : "2024-05-22T20:59:59.295Z" ,
"updatedAt" : "2024-05-22T20:59:59.295Z" ,
"__v" : 0
}
}
```
2024-05-15 12:16:04 -07:00
</details>
2024-05-10 14:34:04 -07:00
2024-05-22 14:38:47 -07:00
<details>
2024-05-25 13:56:19 -05:00
<summary id='post-monitors-del-id'><code>POST</code><b>/api/v1/monitors/delete/{monitorId}</b></summary>
2024-05-22 14:38:47 -07:00
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
> | Type | Notes |
> | ---- | ------------------- |
> | None | No payload returned |
2024-05-22 14:43:07 -07:00
###### Sample CURL request
2024-05-22 14:38:47 -07:00
```
curl --request POST \
--url http://localhost:5000/api/v1/monitors/delete/664e632a7a3ee9d620761938 \
--header '<bearer_token>' \
--header 'Content-Type: application/json' \
```
2024-05-22 14:43:07 -07:00
###### Sample Response
```json
{
"success" : true ,
"msg" : "Monitor deleted"
}
```
2024-05-22 14:38:47 -07:00
## </details>
<details>
2024-05-25 13:56:19 -05:00
<summary id='post-monitors-edit-id'><code>POST</code><b>/api/v1/monitors/edit/{monitorId}</b></summary>
2024-05-22 14:38:47 -07:00
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
> | Type | Notes |
> | --------- | --------------------------- |
> | `Monitor` | Returns the updated monitor |
##### Sample CURL request
```
curl --request POST \
--url http://localhost:5000/api/v1/monitors/edit/664e5ccf189c864800debc16 \
--header '<bearer_token' \
--header 'Content-Type: application/json' \
--data '
{
"_id": "664e5ccf189c864800debc16",
"userId": "6645079aae0b439371913972",
"name": "Edited monitor",
"description": "Description",
"url": "https://monitor0.com",
"isActive": true,
"interval": 60000
}'
```
###### Sample Response
```json
{
"success" : true ,
"msg" : "Monitor edited" ,
"data" : {
"_id" : "664e5ccf189c864800debc16" ,
"userId" : "6645079aae0b439371913972" ,
"name" : "Edited monitor" ,
"description" : "Description" ,
"url" : "https://monitor0.com" ,
"isActive" : true ,
"interval" : 60000 ,
"createdAt" : "2024-05-22T20:59:59.295Z" ,
"updatedAt" : "2024-05-22T21:34:33.893Z" ,
"__v" : 0
}
}
```
2024-05-25 20:14:06 -07:00
</details>
2024-05-25 20:14:24 -07:00
---
2024-05-27 16:04:44 -07:00
###### Checks
<details>
<summary id='post-checks'><code>POST</code><b>/api/v1/checks/{monitorId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
2024-05-29 11:07:17 -07:00
> | Type | Notes |
> | ------- | --------------------------- |
> | `Check` | Returns newly created check |
2024-05-27 16:04:44 -07:00
###### Body
2024-05-29 11:07:17 -07:00
> | 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` | |
2024-05-27 16:04:44 -07:00
##### Sample CURL request
```
2024-05-29 11:07:17 -07:00
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"
}'
2024-05-27 16:04:44 -07:00
```
###### Sample Response
```json
2024-05-29 11:07:17 -07:00
{
"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
}
}
2024-05-27 16:04:44 -07:00
```
</details>
<details>
<summary id='get-checks'><code>GET</code><b>/api/v1/checks/{monitorId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
2024-05-29 11:07:17 -07:00
> | Method | GET |
2024-05-27 16:04:44 -07:00
###### Response Payload
> | Type | Notes |
> | --------------- | ------------------------ |
2024-05-28 13:18:32 -07:00
> | `Array<Checks>` | Array of `Check` objects |
2024-05-27 16:04:44 -07:00
##### Sample CURL request
```
2024-05-29 11:07:17 -07:00
curl --request GET \
--url http://localhost:5000/api/v1/checks/66562414035c4ce6a8a610ac \
--header 'Authorization: <bearer_token>' \
2024-05-27 16:04:44 -07:00
```
###### Sample Response
```json
2024-05-29 11:07:17 -07:00
{
"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
}
]
}
2024-05-27 16:04:44 -07:00
```
</details>
<details>
<summary id='delete-checks'><code>POST</code><b>/api/v1/checks/delete/{monitorId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
2024-05-29 11:07:17 -07:00
> | Type | Notes |
> | -------- | -------------------------------------------------------------------- |
> | `Object` | `{deletedCount: n}` Returns an object showing how many items deleted |
2024-05-27 16:04:44 -07:00
##### Sample CURL request
```
2024-05-29 11:07:17 -07:00
curl --request POST \
--url http://localhost:5000/api/v1/checks/delete/66562414035c4ce6a8a610ac \
--header 'Authorization: <bearer_token>' \
2024-05-27 16:04:44 -07:00
```
###### Sample Response
```json
2024-05-29 11:07:17 -07:00
{
"success" : true ,
"msg" : "Checks deleted" ,
"data" : {
"deletedCount" : 3
}
}
2024-05-27 16:04:44 -07:00
```
</details>
---
2024-05-28 13:18:32 -07:00
###### Alerts
<details>
<summary id='create-alert'><code>POST</code><b>/api/v1/alerts/{monitorId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
> | Type | Notes |
> | ------- | ----------------------------- |
> | `Alert` | Returns newly created `Alert` |
###### Body
2024-05-29 12:30:13 -07:00
"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` | |
2024-05-28 13:18:32 -07:00
##### Sample CURL request
```
```
###### Sample Response
```json
```
</details>
<details>
<summary id='get-alerts-user-id'><code>GET</code><b>/api/v1/alerts/user/{userId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
###### Response Payload
> | Type | Notes |
> | -------------- | --------------------------------------- |
> | `Array<Alert>` | Returns all `Alert` created by a `User` |
##### Sample CURL request
```
2024-05-29 12:30:13 -07:00
curl --request GET \
--url http://localhost:5000/api/v1/alerts/user/6654d1a2634754f789e1f115 \
--header 'Authorization: <bearer_token>'
2024-05-28 13:18:32 -07:00
```
###### Sample Response
```json
2024-05-29 12:30:13 -07:00
{
"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
}
]
}
2024-05-28 13:18:32 -07:00
```
</details>
<details>
<summary id='get-alerts-monitor-id'><code>GET</code><b>/api/v1/alerts/monitor/{monitorId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
###### Response Payload
> | Type | Notes |
> | -------------- | -------------------------------------------------------------- |
> | `Array<Alert>` | Returns an array of `Alert` belonging to a specified `Monitor` |
##### Sample CURL request
```
2024-05-29 12:30:13 -07:00
curl --request GET \
--url http://localhost:5000/api/v1/alerts/monitor/6657789ebf6766ee8e2d2edb \
--header 'Authorization: <bearer_token>' \
2024-05-28 13:18:32 -07:00
```
###### Sample Response
```json
2024-05-29 12:30:13 -07:00
{
"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
}
]
}
2024-05-28 13:18:32 -07:00
```
</details>
<details>
<summary id='get-alert-alert-id'><code>GET</code><b>/api/v1/alerts/{alertId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
###### Response Payload
> | Type | Notes |
> | ------- | ------------------------- |
> | `Alert` | Returns specified `Alert` |
##### Sample CURL request
```
2024-05-29 12:30:13 -07:00
curl --request GET \
--url http://localhost:5000/api/v1/alerts/66577ddae5ff3c91437d0887 \
--header 'Authorization: <bearer_token>' \
2024-05-28 13:18:32 -07:00
```
###### Sample Response
```json
2024-05-29 12:30:13 -07:00
{
"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
}
}
2024-05-28 13:18:32 -07:00
```
</details>
<details>
<summary id='edit-alert'><code>POST</code><b>/api/v1/alerts/edit/{alertId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
2024-05-29 12:30:13 -07:00
> | Type | Notes |
> | ------- | ---------------------- |
> | `Alert` | Returns edited `Alert` |
2024-05-28 13:18:32 -07:00
###### Body
2024-05-29 12:30:13 -07:00
> | 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` | |
2024-05-28 13:18:32 -07:00
##### Sample CURL request
```
2024-05-29 12:30:13 -07:00
curl --request POST \
--url http://localhost:5000/api/v1/alerts/edit/66577ddae5ff3c91437d0887 \
--header 'Authorization: <bearer_token>' \
--header 'Content-Type: application/json' \
--data '{
"acknowledgeStatus": true
}'
2024-05-28 13:18:32 -07:00
```
###### Sample Response
```json
2024-05-29 12:30:13 -07:00
{
"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
}
}
2024-05-28 13:18:32 -07:00
```
</details>
<details>
<summary id='delete-alert'><code>POST</code><b>/api/v1/alerts/delete/{alertId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
2024-05-29 12:30:13 -07:00
> | Type | Notes |
> | ------- | --------------------------- |
> | `Alert` | Returns the deleted `Alert` |
2024-05-28 13:18:32 -07:00
##### Sample CURL request
```
2024-05-29 12:30:13 -07:00
curl --request POST \
--url http://localhost:5000/api/v1/alerts/delete/66577ddae5ff3c91437d0887 \
--header 'Authorization: <bearer_token>' \
2024-05-28 13:18:32 -07:00
```
###### Sample Response
```json
2024-05-29 12:30:13 -07:00
{
"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
}
}
2024-05-28 13:18:32 -07:00
```
</details>
---
2024-06-05 13:23:43 -07:00
###### Checks
<details>
<summary id='post-checks'><code>POST</code><b>/api/v1/checks/{monitorId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
> | Type | Notes |
> | ------- | --------------------------- |
> | `Check` | Returns newly created check |
###### 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
```
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
```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>
<summary id='get-checks'><code>GET</code><b>/api/v1/checks/{monitorId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
###### Response Payload
> | Type | Notes |
> | --------------- | ------------------------ |
> | `Array<Checks>` | Array of `Check` objects |
##### Sample CURL request
```
curl --request GET \
--url http://localhost:5000/api/v1/checks/66562414035c4ce6a8a610ac \
--header 'Authorization: <bearer_token>' \
```
###### Sample Response
```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>
<summary id='delete-checks'><code>POST</code><b>/api/v1/checks/delete/{monitorId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
> | Type | Notes |
> | -------- | -------------------------------------------------------------------- |
> | `Object` | `{deletedCount: n}` Returns an object showing how many items deleted |
##### Sample CURL request
```
curl --request POST \
--url http://localhost:5000/api/v1/checks/delete/66562414035c4ce6a8a610ac \
--header 'Authorization: <bearer_token>' \
```
###### Sample Response
```json
{
"success" : true ,
"msg" : "Checks deleted" ,
"data" : {
"deletedCount" : 3
}
}
```
</details>
---
###### Alerts
<details>
<summary id='create-alert'><code>POST</code><b>/api/v1/alerts/{monitorId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
> | Type | Notes |
> | ------- | ----------------------------- |
> | `Alert` | Returns newly created `Alert` |
###### 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 Response
```json
```
</details>
<details>
<summary id='get-alerts-user-id'><code>GET</code><b>/api/v1/alerts/user/{userId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
###### Response Payload
> | Type | Notes |
> | -------------- | --------------------------------------- |
> | `Array<Alert>` | Returns all `Alert` created by a `User` |
##### Sample CURL request
```
curl --request GET \
--url http://localhost:5000/api/v1/alerts/user/6654d1a2634754f789e1f115 \
--header 'Authorization: <bearer_token>'
```
###### Sample Response
```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>
<summary id='get-alerts-monitor-id'><code>GET</code><b>/api/v1/alerts/monitor/{monitorId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
###### Response Payload
> | Type | Notes |
> | -------------- | -------------------------------------------------------------- |
> | `Array<Alert>` | Returns an array of `Alert` belonging to a specified `Monitor` |
##### Sample CURL request
```
curl --request GET \
--url http://localhost:5000/api/v1/alerts/monitor/6657789ebf6766ee8e2d2edb \
--header 'Authorization: <bearer_token>' \
```
###### Sample Response
```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>
<summary id='get-alert-alert-id'><code>GET</code><b>/api/v1/alerts/{alertId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
###### Response Payload
> | Type | Notes |
> | ------- | ------------------------- |
> | `Alert` | Returns specified `Alert` |
##### Sample CURL request
```
curl --request GET \
--url http://localhost:5000/api/v1/alerts/66577ddae5ff3c91437d0887 \
--header 'Authorization: <bearer_token>' \
```
###### Sample Response
```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>
<summary id='edit-alert'><code>POST</code><b>/api/v1/alerts/edit/{alertId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
> | Type | Notes |
> | ------- | ---------------------- |
> | `Alert` | Returns edited `Alert` |
###### 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
```
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
```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>
<summary id='delete-alert'><code>POST</code><b>/api/v1/alerts/delete/{alertId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | POST |
###### Response Payload
> | Type | Notes |
> | ------- | --------------------------- |
> | `Alert` | Returns the deleted `Alert` |
##### Sample CURL request
```
curl --request POST \
--url http://localhost:5000/api/v1/alerts/delete/66577ddae5ff3c91437d0887 \
--header 'Authorization: <bearer_token>' \
```
###### Sample Response
```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>
---
2024-05-28 10:41:10 -07:00
### Error handling
2024-05-27 11:03:12 -07:00
Errors are returned in a standard format:
`{"success": false, "msg": "No token provided"}`
Errors are handled by error handling middleware and should be thrown with the following parameters
| Name | Type | Default | Notes |
| ------- | --------- | ---------------------- | ------------------------------------ |
| status | `integer` | 500 | Standard HTTP codes |
| message | `string` | "Something went wrong" | An error message |
| service | `string` | "Unknown Service" | Name of service that threw the error |
Example:
```
const myRoute = async(req, res, next) => {
try{
const result = myRiskyOperationHere();
}
catch(error){
error.status = 404
error.message = "Resource not found"
error.service = service name
next(error)
return;
}
}
```
Errors should not be handled at the controller level and should be left to the middleware to handle.
2024-05-10 02:16:50 -04:00
## Contributors
2024-05-10 14:34:04 -07:00
2024-05-10 02:16:50 -04:00
<a href="https://github.com/bluewave-labs/bluewave-uptime/graphs/contributors">
<img src="https://contrib.rocks/image?repo=bluewave-labs/bluewave-uptime" />
2024-05-10 02:45:41 -04:00
</a>
2024-05-22 16:46:09 -04:00
Made with [contrib.rocks ](https://contrib.rocks ).