mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-10 19:59:39 -06:00
ce0cf9cb836dd696faf33b5996304cba00a986ec
BlueWave Uptime
BlueWave uptime monitoring application
Getting Started
- Clone this repository to your local machine
- Installation (Client)
- Installation (Server)
- Configuration(Server)
- Endpoints
Auth
POST/api/v1/auth/registerPOST/api/v1/auth/loginPOST/api/v1/auth/user/{userId}
Monitors
GET/api/v1/monitorsGET/api/v1/monitor/{id}GET/api/v1/monitors/user/{userId}POST/api/v1/monitorsPOST/api/v1/monitors/delete/{monitorId}POST/api/v1/monitors/edit/{monitorId}
Checks
POST/api/v1/checks/{monitorId}GET/api/v1/checks/{monitorId}POST/api/v1/checks/delete/{monitorId}
Alerts
- Error Handling
- Contributors
Client
Installation
- Change directory to the
Clientdirectory - Install all dependencies by running
npm install
Starting Development Server
- Run
npm run devto start the development server.
Server
Installation
- Change directory to the
Serverdirectory - Install all dependencies by running
npm install
Configuration
Configure the server with the following environmental variables
| ENV Variable Name | Required/Optional | Type | Description | Accepted Values |
|---|---|---|---|---|
| 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 | |
| MAILERSEND_API_KEY | Required | string |
Specifies API KEY for MailerSend service | |
| SYSTEM_EMAIL_ADDRESS | Required | string |
Specifies System email to be used in emailing service |
Starting the Development Server
- run
npm run devto start the development server
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}}
Data Types
User
| Name | Type | Notes |
|---|---|---|
| firstname | string |
First name |
| lastname | string |
Last name |
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 |
Monitor
| 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 |
Check
| 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 |
Alert
| Name | Type | Notes |
|---|---|---|
| checkId | string |
Unique ID for the associated check |
| monitorId | string |
Unique ID for the associated monitor |
| userId | string |
Unique ID for the associated user |
| status | boolean |
Indicates the service is Up or Down |
| 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 |
Auth
POST /api/v1/auth/register
Method/Headers
Method/Headers Value Method POST content-type application/json
Body
Name Type Notes firstname stringlastname stringstringValid email address password stringMin 8 chars
Response Payload
Type Notes JWT JSON Web Token containing a User
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
{
"success": true,
"msg": "User created",
"data": "<encoded_user>"
}
POST /api/v1/auth/login
Method/Headers
Method/Headers Value Method POST content-type application/json
Body
Name Type Notes stringValid email address password stringMin 8 chars
Response Payload
Type Notes JWT JSON Web Token Containing a User
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
{
"success": true,
"msg": "Found user",
"data": "<encoded_user>"
}
POST/api/v1/auth/user/{userId}
Method/Headers
Method/Headers Value Method POST
Body
Name Type Notes firstname stringlastname stringprofilePicUrl stringpassword stringMin 8 chars
Response Payload
Type Notes UserReturns 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
{
"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
}
}
Monitors
GET /api/v1/monitors
Method/Headers
Method/Headers Value Method GET
Response Payload
Type Notes Array<Monitor>Array of all monitors
Sample cURL Request
curl --request GET \
--url http://localhost:5000/api/v1/monitors \
--header '<bearer_token>' \
Sample Response
{
"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
}
]
}
GET /api/v1/monitor/{id}
Method/Headers
Method/Headers Value Method GET
Response Payload
Type Notes MonitorSingle monitor with the id in the request parameter
Sample cURL Request
curl --request GET \
--url http://localhost:5000/api/v1/monitors/664d070786e62625ac612ca1 \
--header '<bearer_token>' \
Sample Response
{
"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
}
}
GET /api/v1/monitors/user/{userId}
Method/Headers
Method/Headers Value Method GET
Response Payload
Type Notes Array<Monitor>Array of monitors created by user with specified UserID
Sample cURL Request
curl --request GET \
--url http://localhost:5000/api/v1/monitors/user/6645079aae0b439371913972 \
--header '<bearer_token>' \
Sample Response
{
"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
}
]
}
POST/api/v1/monitors
Method/Headers
Method/Headers Value Method POST
Response Payload
Type Notes MonitorReturns newly created Monitor
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
{
"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
}
}
POST/api/v1/monitors/delete/{monitorId}
Method/Headers
Method/Headers Value Method POST
Response Payload
Type Notes None No payload returned
Sample CURL request
curl --request POST \
--url http://localhost:5000/api/v1/monitors/delete/664e632a7a3ee9d620761938 \
--header '<bearer_token>' \
--header 'Content-Type: application/json' \
Sample Response
{
"success": true,
"msg": "Monitor deleted"
}
POST/api/v1/monitors/edit/{monitorId}
Method/Headers
Method/Headers Value Method POST
Response Payload
Type Notes MonitorReturns 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
{
"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
}
}
Checks
POST/api/v1/checks/{monitorId}
Method/Headers
Method/Headers Value Method POST
Response Payload
Type Notes None No payload returned
Body
Sample CURL request
Sample Response
GET/api/v1/checks/{monitorId}
Method/Headers
Method/Headers Value Method POST
Response Payload
Type Notes Array<Checks>Array of Checkobjects
Sample CURL request
Sample Response
POST/api/v1/checks/delete/{monitorId}
Method/Headers
Method/Headers Value Method POST
Response Payload
Type Notes None No payload returned
Body
Sample CURL request
Sample Response
Alerts
POST/api/v1/alerts/{monitorId}
Method/Headers
Method/Headers Value Method POST
Response Payload
Type Notes AlertReturns newly created Alert
Body
Sample CURL request
Sample Response
GET/api/v1/alerts/user/{userId}
Method/Headers
Method/Headers Value Method GET
Response Payload
Type Notes Array<Alert>Returns all Alertcreated by aUser
Sample CURL request
Sample Response
GET/api/v1/alerts/monitor/{monitorId}
Method/Headers
Method/Headers Value Method GET
Response Payload
Type Notes Array<Alert>Returns an array of Alertbelonging to a specifiedMonitor
Sample CURL request
Sample Response
GET/api/v1/alerts/{alertId}
Method/Headers
Method/Headers Value Method GET
Response Payload
Type Notes AlertReturns specified Alert
Sample CURL request
Sample Response
POST/api/v1/alerts/edit/{alertId}
Method/Headers
Method/Headers Value Method POST
Response Payload
Type Notes AlertReturns edited alert
Body
Sample CURL request
Sample Response
POST/api/v1/alerts/delete/{alertId}
Method/Headers
Method/Headers Value Method POST
Response Payload
Type Notes None No payload returned
Body
Sample CURL request
Sample Response
Error handling
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.
Contributors
Made with contrib.rocks.
Languages
JavaScript
93.8%
TypeScript
3.5%
Shell
1.7%
CSS
0.7%
Dockerfile
0.3%