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

  1. API Path: api/users/register
  2. 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.
  3. Parameters:

    • Name: req
    • Type: Object

    | Name | Type | Required | | :--- | :--- | :--- | | email | String | true | | password | String | true | | fname | String | true | | lname | String | true | | phoneNo | Number | true | | userType | String | true |

  4. 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 Route

  1. API Path: api/users
  2. Method: GET
  3. Description: This is a protected route which gets the user details through JWT access token which is provided in the header.
  4. Parameters:

    • Name: jwtAccessToken
    • In: Header
    • Type: String
    • Description: JWT access token is used to check the authenticity of the user.
  5. Name: res

  6. Type: Object

  7. Description: res is nothing but the response object which gets you the user details.

  8. Response:

    • Http Code: 200
    • Name: returnObj
    • Type: Object

    | Name | Type | | :--- | :--- | | success | boolean | | message | string | | data | Object |

Update User Details Route

  1. API Path: api/users
  2. Method: PUT
  3. Description: This is a protected route which update the user details.
  4. Parameters:

    • Name: req
    • Type: Object

    | Name | Type | | :--- | :--- | | email | 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.
  5. Response:

    • Http Code: 200
    • Name: returnObj
    • Type: Object

    | Name | Type | | :--- | :--- | | success | boolean | | message | string | | data | Object |

Delete User Details Route

  1. API Path: api/users
  2. Method: DELETE
  3. Description: Remove a user from the database.
  4. Parameters:

    • Name: req
    • Type: Object
  5. Name: jwtAccessToken

  6. In: Header

  7. Type: String

  8. Name: res

  9. Type: Object

  10. Response:

    • Http Code: 204
    • data: { }
    • Type: Object

    | Name | Type | | :--- | :--- | | statusCode | status | | data | blank Object |

results matching ""

    No results matching ""