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
  2. Method: POST
  3. 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.
  4. Parameters:

    • Name: req
    • Type: Object
Name Type Required
email String true
password String true
name String true
city String true
zip Number true
contactNumber Number true
  1. 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

  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/{id}
  2. Method: PUT
  3. Description: This is a protected route which update the user details.
  4. Parameters:

    • Name: req
    • Type: Object
    • id:entity id
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.

  • 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: 200
    • Name: returnObj
    • Type: Object
Name Type
success boolean
message string
data Object

Get A Single User Detail Route

  1. API Path:

    api/users/{id}

    1. **Method
      ** GET
  2. Description:
    gets a user from the database

    Parameter

  3. id:Id of a User(_id of document)

results matching ""

    No results matching ""