Removed password from returned user, updated readme
This commit is contained in:
1 parent
78abdd7f70
commit
7672cd5530
3 files changed
+63
-3
No files matched your search
@@ -12,6 +12,7 @@ BlueWave uptime monitoring application
|
|||||||
4. [Endpoints](#endpoints)
|
4. [Endpoints](#endpoints)
|
||||||
- <code>POST</code> [/api/v1/auth/register](#post-register)
|
- <code>POST</code> [/api/v1/auth/register](#post-register)
|
||||||
- <code>POST</code> [/api/v1/auth/login](#post-login)
|
- <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/monitors](#get-monitors)
|
||||||
- <code>GET</code> [/api/v1/monitor/{id}](#get-monitor-id)
|
- <code>GET</code> [/api/v1/monitor/{id}](#get-monitor-id)
|
||||||
- <code>GET</code> [/api/v1/monitors/user/{userId}](#get-monitors-user-userid)
|
- <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>
|
<details>
|
||||||
<summary id='get-monitors'><code>GET</code> <b>/api/v1/monitors</b></summary>
|
<summary id='get-monitors'><code>GET</code> <b>/api/v1/monitors</b></summary>
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ const updateUser = async (req, res) => {
|
|||||||
candidateUserId,
|
candidateUserId,
|
||||||
candidateUser,
|
candidateUser,
|
||||||
{ new: true } // Returns updated user instead of pre-update user
|
{ new: true } // Returns updated user instead of pre-update user
|
||||||
);
|
).select("-password");
|
||||||
return updatedUser;
|
return updatedUser;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
const router = require("express").Router();
|
const router = require("express").Router();
|
||||||
const user = require("../models/user");
|
|
||||||
const { verifyJWT } = require("../middleware/verifyJWT");
|
const { verifyJWT } = require("../middleware/verifyJWT");
|
||||||
const { verifyOwnership } = require("../middleware/verifyOwnership");
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
registerController,
|
registerController,
|
||||||
|
|||||||
Reference in new issue
Block a user