Removed password from returned user, updated readme

This commit is contained in:
Alex Holliday committed 2024-05-27 12:27:57 -07:00
1 parent 78abdd7f70
commit 7672cd5530
3 files changed
+63 -3

No files matched your search

+62
View File
@@ -12,6 +12,7 @@ BlueWave uptime monitoring application
4. [Endpoints](#endpoints)
- <code>POST</code> [/api/v1/auth/register](#post-register)
- <code>POST</code> [/api/v1/auth/login](#post-login)
- <code>POST</code> [/api/v1/auth/user/{userId}](#post-auth-user-edit-id)
- <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)
@@ -222,6 +223,67 @@ curl --request POST \
---
<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>
---
<details>
<summary id='get-monitors'><code>GET</code> <b>/api/v1/monitors</b></summary>
+1 -1
View File
@@ -73,7 +73,7 @@ const updateUser = async (req, res) => {
candidateUserId,
candidateUser,
{ new: true } // Returns updated user instead of pre-update user
);
).select("-password");
return updatedUser;
} catch (error) {
throw error;
-2
View File
@@ -1,7 +1,5 @@
const router = require("express").Router();
const user = require("../models/user");
const { verifyJWT } = require("../middleware/verifyJWT");
const { verifyOwnership } = require("../middleware/verifyOwnership");
const {
registerController,