|
17 | 17 |
|
18 | 18 | * This API is return all customer's list if the following conditions are matched
|
19 | 19 | * Method : GET
|
| 20 | + * If user role is admin |
20 | 21 | * If user is loggedIn then pass JWT token into header
|
21 |
| - Like: https://drive.google.com/file/d/1Zu2J8KOgQIaAvjcqwvPZMq_Ol7gRemHz/view |
| 22 | + Likes: https://drive.google.com/file/d/1Zu2J8KOgQIaAvjcqwvPZMq_Ol7gRemHz/view |
22 | 23 | * If user is not loggedIn then this will return following response
|
23 |
| - Link: https://drive.google.com/file/d/1hTq_3DeTljQP0KGzhCU0fYS9NtBNWlTu/view?usp=drivesdk |
| 24 | + Links: https://drive.google.com/file/d/1hTq_3DeTljQP0KGzhCU0fYS9NtBNWlTu/view?usp=drivesdk |
24 | 25 |
|
25 |
| - * |
26 |
| - |
| 26 | + * http://localhost:3000/auth/register |
| 27 | + * This API is used for register customer using following condition's |
| 28 | + * Method : PUT (reason for put methods here because we want to insert new resource ) |
| 29 | + * In this API just pass header Content-Type: application/json or whatever you want in to response |
| 30 | + * The purpose to use this API is to register user with the specific role like : user,admin |
| 31 | + * Please check Restlet Client schreenshot for more clarification |
| 32 | + Links: https://drive.google.com/file/d/1urhWZ7WmhViCsKUzNB6xd9ghC7Sg93l1/view?usp=drivesdk |
| 33 | + |
| 34 | + * http://localhost:3000/auth/login |
| 35 | + * This API is used for login of the customer using the following condition |
| 36 | + * Pass email/password of the customer header Content-Type: application/json or whatever you want in to response. |
| 37 | + * If the user is registered user then this will return JWT token with message : "Success" |
| 38 | + * If the user is not found then simply return message": "User not found." |
| 39 | + |
| 40 | + * http://localhost:3000/getUserDetails |
| 41 | + * Method : GET |
| 42 | + * This API return user details when user pass JWT token and email id of the customer based on the email id the data is return |
| 43 | + * This API is return customer details only when the role of the user is admin |
| 44 | + * Pass emailId from query parameters |
| 45 | + Links: https://drive.google.com/file/d/1Fw03ZzG60J8hkWfzV7hv4q0wsOLjQIwm/view?usp=drivesdk |
| 46 | + |
| 47 | + * http://localhost:3000/updateUser |
| 48 | + * Method : POST |
| 49 | + * Same condition's like getUserDetails API but where user and customer both can update data |
| 50 | + Links: https://drive.google.com/file/d/1CInwrTVvdcPLCXvmuaFO1V_SMUDwVxNq/view?usp=drivesdk |
| 51 | + |
| 52 | + * http://localhost:3000/deleteUser |
| 53 | + * Method : POST |
| 54 | + * This API is use to delete all customer from database |
| 55 | + * The role of the user should be admin |
| 56 | + * This just return { message: 'Customer record successfully deleted' } if user is admin otherwise |
| 57 | + { message: "Unauthorised access" } |
| 58 | + |
| 59 | + |
| 60 | + Code Explanation : |
| 61 | + |
| 62 | + * Middleware |
| 63 | + * The purpose to add middleware here is to check if the user is passing JWT token or not |
| 64 | + Before calling API |
| 65 | + * If user passing JWT token then we assign the user is defined |
| 66 | + * If user does not passing the JWT token the we assign the user is undefined |
| 67 | + Links: https://drive.google.com/file/d/1nGQlXKOLxDuZSyUbsd34AsuWfHmgOnpU/view?usp=drivesdk |
| 68 | + |
| 69 | + * Routes: |
| 70 | + * Check this links https://drive.google.com/file/d/1Oq-mtwhjhXxbd0PIFcRtO_klAYhsBE7A/view?usp=drivesdk |
| 71 | + for more information |
| 72 | + * As you can see there is one function is called on most of API routes which is userHandlers.loginRequired |
| 73 | + the purpose to user this function is that we want to disallow customer to access these API |
| 74 | + directly these API is only and only access by the user if the user is login |
| 75 | + |
| 76 | + Thanks for reading this document hope you enjoy this documents |
| 77 | + feel free to ask if you have any doubts |
| 78 | + |
0 commit comments