Routes - User
File Name: user.js
File Path: /server/routes/user.js
Contains route which register, update, view and delete the user details. These functionalities are included in User Controller.
Registration Route
- API Path: api/users
- Method: POST
- Description: Register route is used to register a new user. User can be either a Rider or a Driver. This route also checks if user has already been registered or not.
Parameters:
- Name: req
- Type: Object
Name | Type | Required |
---|---|---|
String | true | |
password | String | true |
name | String | true |
city | String | true |
zip | Number | true |
contactNumber | Number | true |
Response: Returns an object with three properties: success (bool), message, data. The third parameter data is an object with two properties: jwtAccessToken and user object.
- Http Code: 200
- Name: returnObj
- Type: Object
Name | Type |
---|---|
success | boolean |
message | string |
data | Object |
Get User Details
- API Path: api/users
- Method: GET
- Description: This is a protected route which gets the user details through JWT access token which is provided in the header.
Parameters:
- Name: jwtAccessToken
- In: Header
- Type: String
- Description: JWT access token is used to check the authenticity of the user.
Name: res
Type: Object
Description: res is nothing but the response object which gets you the user details.
Response:
- Http Code: 200
- Name: returnObj
- Type: Object
Name | Type |
---|---|
success | boolean |
message | string |
data | Object |
Update User Details Route
- API Path: api/users/{id}
- Method: PUT
- Description: This is a protected route which update the user details.
Parameters:
- Name: req
- Type: Object
- id:entity id
Name | Type |
---|---|
String | |
password | String |
fname | String |
lname | String |
phoneNo | Number |
- Name: jwtAccessToken
- In: Header
- Type: String
Description: JWT access token is used to check the authenticity of the user.
Response:
- Http Code: 200
- Name: returnObj
- Type: Object
Name | Type |
---|---|
success | boolean |
message | string |
data | Object |
Delete User Details Route
- API Path: api/users
- Method: DELETE
- Description: Remove a user from the database.
Parameters:
- Name: req
- Type: Object
Name: jwtAccessToken
In: Header
Type: String
Name: res
Type: Object
Response:
- Http Code: 200
- Name: returnObj
- Type: Object
Name | Type |
---|---|
success | boolean |
message | string |
data | Object |
Get A Single User Detail Route
API Path:
api/users/{id}
- **Method
** GET
- **Method
Description:
gets a user from the databaseParameter
id:Id of a User(_id of document)