Added login route, updated readme

This commit is contained in:
Alex Holliday committed 2024-05-15 12:16:04 -07:00
1 parent 4f3bbb2f88
commit e7a58f2756
6 files changed
+272 -55

No files matched your search

+191 -37
View File
@@ -34,10 +34,10 @@ BlueWave uptime monitoring application
Configure the server with the following environmental variables
| ENV Varialbe Name | Required/Optional | Type | Description |
| -------------------- | ----------------- | ------ | --------------------------------- |
| DB_CONNECTION_STRING | Required | string | Specfies URL for MongoDB Database |
| MAILERSEND_API_KEY | Required | string | Specfies API KEY for MailerSend service |
| ENV Varialbe Name | Required/Optional | Type | Description |
| -------------------- | ----------------- | ------ | ---------------------------------------------------- |
| DB_CONNECTION_STRING | Required | string | Specfies URL for MongoDB Database |
| MAILERSEND_API_KEY | Required | string | Specfies API KEY for MailerSend service |
| SYSTEM_EMAIL_ADDRESS | Required | string | Specfies System email to be used in emailing service |
---
@@ -64,9 +64,28 @@ Example:
{success: true, msg: "Successful Request", data: {test: testData}}
```
---
##### Data Types
###### Monitor
<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>
| Name | Type | Notes |
| ----------- | --------- | ---------------------------------------- |
@@ -79,51 +98,186 @@ Example:
| updatedAt | `Date` | Last time the monitor was updated |
| CreatedAt | `Date` | When the monitor was updated |
---
##### GET /api/v1/monitors
###### Response
| Status Code | Type | Description |
| ----------- | --------------------- | -------------------------------- |
| 200 | Response with Payload | Response with a list of monitors |
###### Payload
| Type | Notes |
| ---------------- | ----------------- |
| `Array[Monitor]` | Array of monitors |
</details>
---
##### GET /api/v1/monitor/:id
<details>
<summary><code>POST</code> <b>/api/v1/auth/register</b></summary>
###### Response
##### Method/Headers
| Status Code | Type | Description |
| ----------- | --------------------- | ------------------------------ |
| 200 | Response with Payload | Response with a single monitor |
> | Method/Headers | Value |
> | -------------- | ---------------- |
> | Method | POST |
> | content-type | application/json |
###### Payload
##### Body
| Type | Notes |
| --------- | --------------------------------------------------- |
| `Monitor` | Single monitor with the id in the request parameter |
> | Name | Type | Notes |
> | --------- | -------- | ------------------- |
> | firstname | `string` | |
> | lastname | `string` |
> | email | `string` | Valid email address |
> | password | `string` | Min 8 chars |
##### Response Payload
> | Type | Notes |
> | ------ | ---------- |
> | `User` | User model |
##### 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,
"msg": "User created}",
"data": {
"_id": "6645079aae0b439371913972",
"firstname": "User First Name",
"lastname": "User Last Name",
"email": "user@gmail.com",
"isActive": true,
"isVerified": false,
"updated_at": "2024-05-15T19:06:02.720Z",
"created_at": "2024-05-15T19:06:02.720Z",
"__v": 0
}
}
```
</details>
---
##### GET /api/v1/monitors/user/:userId
<details>
<summary><code>POST</code> <b>/api/v1/auth/login</b></summary>
| Status Code | Type | Description |
| ----------- | --------------------- | -------------------------------- |
| 200 | Response with Payload | Response with a list of monitors |
##### Method/Headers
###### Payload
> | Method/Headers | Value |
> | -------------- | ---------------- |
> | Method | POST |
> | content-type | application/json |
| Type | Notes |
| ---------------- | ------------------------------------------------------------------ |
| `Array[Monitor]` | Array of monitors created by user with userId specified in request |
##### Body
> | Name | Type | Notes |
> | -------- | -------- | ------------------- |
> | email | `string` | Valid email address |
> | password | `string` | Min 8 chars |
##### Response Payload
> | Type | Notes |
> | ------ | ---------- |
> | `User` | User model |
##### 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",
"data": {
"_id": "6644fb9bae0b439371913969",
"firstname": "User First Name",
"lastname": "User Last Name",
"email": "user@gmail.com",
"isActive": true,
"isVerified": false,
"updated_at": "2024-05-15T18:14:51.049Z",
"created_at": "2024-05-15T18:14:51.049Z",
"__v": 0
}
}
```
</details>
---
<details>
<summary><code>GET</code> <b>/api/v1/monitors</b></summary>
##### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
##### Response Payload
> | Type | Notes |
> | ---------------- | ----------------- |
> | `Array[Monitor]` | Array of monitors |
</details>
---
<details>
<summary><code>GET</code> <b>/api/v1/monitor/{id}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
###### Response Payload
> | Type | Notes |
> | --------- | --------------------------------------------------- |
> | `Monitor` | Single monitor with the id in the request parameter |
</details>
---
<details>
<summary><code>GET</code> <b>/api/v1/monitors/user/{userId}</b></summary>
###### Method/Headers
> | Method/Headers | Value |
> | -------------- | ----- |
> | Method | GET |
###### Request Payload
> | Type | Notes |
> | ---------------- | ------------------------------------------------------------------ |
> | `Array[Monitor]` | Array of monitors created by user with userId specified in request |
</details>
## Contributors