Merge pull request #79 from bluewave-labs/feat/server-db-images
Added docker images for MongoDB and Redis to project. Resolves #65
This commit is contained in:
4 files changed
+523
-4
No files matched your search
@@ -9,6 +9,9 @@ BlueWave uptime monitoring application
|
||||
1. [Installation (Client)](#client)
|
||||
2. [Installation (Server)](#server)
|
||||
3. [Configuration(Server)](#config-server)
|
||||
- [Environment](#environmental-variables)
|
||||
- [Database](#databases)
|
||||
- [Docker Images](#docker-images)
|
||||
4. [Endpoints](#endpoints)
|
||||
###### Auth
|
||||
- <code>POST</code> [/api/v1/auth/register](#post-register)
|
||||
@@ -59,9 +62,11 @@ BlueWave uptime monitoring application
|
||||
|
||||
---
|
||||
|
||||
#### Configuration {#config-server}
|
||||
#### Configuration <a id="config-server"></a>
|
||||
|
||||
Configure the server with the following environmental variables
|
||||
##### Environmental Variables
|
||||
|
||||
Configure the server with the following environmental variables:
|
||||
|
||||
| ENV Variable Name | Required/Optional | Type | Description | Accepted Values |
|
||||
| -------------------- | ----------------- | --------- | ------------------------------------------------------------------------------------------- | ------------------- |
|
||||
@@ -74,6 +79,45 @@ Configure the server with the following environmental variables
|
||||
|
||||
---
|
||||
|
||||
##### Databases
|
||||
|
||||
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.
|
||||
|
||||
You may run your own databases locally, or you may use the docker images included in the project to get up and running quickly.
|
||||
|
||||
###### (Optional) Running Docker Images <a id="docker-images"></a>
|
||||
|
||||
Docker images are located in `./Server/docker`
|
||||
|
||||
<details>
|
||||
<summary><b>MongoDB Image</b></summary>
|
||||
Located in `./Server/docker/mongo`
|
||||
|
||||
The `./Server/docker/mongo/mongo_data` folder should be mounted to the MongoDB container in order to persist data.
|
||||
|
||||
From the `mongo` folder run
|
||||
|
||||
1. Build the image: `docker build -t <db_image_name> .`
|
||||
2. Run the docker image: `docker run -d -p 27017:27017 -v $(pwd)/../mongo/mongo_data:/data/db --name uptime_database_mongo uptime_database_mongo`
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary><b>Redis Image</b></summary>
|
||||
Located in `./Server/docker/redis`
|
||||
|
||||
the `./Server/docker/redis/redis_data` folder should be mounted to the Redis container in order to persist data.
|
||||
|
||||
From the `Redis` folder run
|
||||
|
||||
1. Build the image: `docker build -t <db_image_name>`
|
||||
2. Run the image: `docker run -d -p 6379:6379 -v $(pwd)/../redis/redis_data:/data --name uptime_redis uptime_redis`
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
#### Starting the Development Server
|
||||
|
||||
1. run `npm run dev` to start the development server
|
||||
@@ -1110,7 +1154,475 @@ curl --request POST \
|
||||
|
||||
---
|
||||
|
||||
### Error handling {#error-handling}
|
||||
###### 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>
|
||||
|
||||
---
|
||||
|
||||
### Error handling
|
||||
|
||||
Errors are returned in a standard format:
|
||||
|
||||
|
||||
+4
-1
@@ -1,3 +1,6 @@
|
||||
node_modules
|
||||
.env
|
||||
*.log
|
||||
*.log
|
||||
*.sh
|
||||
docker/mongo/mongo_data/*
|
||||
docker/redis/redis_data/*
|
||||
@@ -0,0 +1,2 @@
|
||||
FROM mongo
|
||||
EXPOSE 27017
|
||||
@@ -0,0 +1,2 @@
|
||||
FROM redis
|
||||
EXPOSE 6379
|
||||
Reference in new issue
Block a user