Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend API Documentation

/users/register Endpoint

Description

This endpoint is used to register a new user. It validates the input data and creates a new user in the database.

HTTP Method

POST

Endpoint

/users/register

Request Body

The request body should be a JSON object with the following fields:

  • fullname (object) :
    • firstname (string,required): User's first name (min 3 characters)
    • lastname (string,optional): User's last name (min 3 charcaters)
  • email (string,required): User's email address(must be a valid address)
  • password (string,required) : User's password (min 6 characters)

Example response

  • user: (object) :
    • fullname: (object).
      • firstname (string):User's first name (min 3 characters)
      • lastname (string):User's last name (min 3 charcaters)
    • email (string):User's email address(must be a valid address)
    • password (string):User's password (min 6 characters)
  • token (string): JWT token

Example:

{
  "fullname": {
    "firstname": "John",
    "lastname": "Doe"
  },
  "email": "john.doe@example.com",
  "password": "password123"
}

/users/login Endpoint

Description

This endpoint is used to log in an existing user. It validates the input data and returns a JWT token if the credentials are correct.

HTTP Method

POST

Endpoint

/users/login

Request Body

The request body should be a JSON object with the following fields:

  • email (string,required): User's email address (must be a valid address)
  • password (string,required): User's password (min 6 characters)

Example response

  • user: (object) :
    • fullname: (object).
      • firstname (string):User's first name
      • lastname (string):User's last name
    • email (string):User's email address
    • password (string):Users password
  • token (string): JWT token

Example:

{
  "email": "john.doe@example.com",
  "token": "jwt-token"
}

/users/profile Endpoint

Description

This endpoint is used to get the profile of the authenticated user.

HTTP Method

GET

Endpoint

/users/profile

Example response

  • user: (object) :
    • fullname: (object).
      • firstname (string):User's first name
      • lastname (string):User's last name
    • email (string):User's email address

Example:

{
  "fullname": {
    "firstname": "John",
    "lastname": "Doe"
  },
  "email": "john.doe@example.com"
}

/users/logout Endpoint

Description

This endpoint is used to log out the authenticated user.

HTTP Method

POST

Endpoint

/users/logout

Example response

  • message (string): Confirmation message

Example:

{
  "message": "Logged Out"
}

Backend API Documentation

/captain/register Endpoint

Description

This endpoint is used to register a new captain. It validates the input data and creates a new captain in the database.

HTTP Method

POST

Endpoint

/captain/register

Request Body

The request body should be a JSON object with the following fields:

  • fullname (object) :
    • firstname (string, required): Captain's first name (min 3 characters)
    • lastname (string, optional): Captain's last name (min 3 characters)
  • email (string, required): Captain's email address (must be a valid address)
  • password (string, required): Captain's password (min 6 characters)
  • vehicle (object):
    • color (string, required): Vehicle color (min 3 characters)
    • plate (string, required): Vehicle plate (min 3 characters)
    • capacity (number, required): Vehicle capacity (min 1)
    • vehicleType (string, required): Vehicle type (must be one of 'car', 'motorcycle', 'auto')

Example response

  • captain: (object):
    • fullname: (object):
      • firstname (string): Captain's first name
      • lastname (string): Captain's last name
    • email (string): Captain's email address
    • vehicle: (object):
      • color (string): Vehicle color
      • plate (string): Vehicle plate
      • capacity (number): Vehicle capacity
      • vehicleType (string): Vehicle type
  • token (string): JWT token

Example:

{
  "fullname": {
    "firstname": "Jane",
    "lastname": "Doe"
  },
  "email": "jane.doe@example.com",
  "password": "password123",
  "vehicle": {
    "color": "red",
    "plate": "ABC123",
    "capacity": 4,
    "vehicleType": "car"
  }
}

/captain/login Endpoint

Description

This endpoint is used to log in an existing captain. It validates the input data and returns a JWT token if the credentials are correct.

HTTP Method

POST

Endpoint

/captain/login

Request Body

The request body should be a JSON object with the following fields:

  • email (string, required): Captain's email address (must be a valid address)
  • password (string, required): Captain's password (min 6 characters)

Example response

  • captain: (object):
    • fullname: (object):
      • firstname (string): Captain's first name
      • lastname (string): Captain's last name
    • email (string): Captain's email address
    • vehicle: (object):
      • color (string): Vehicle color
      • plate (string): Vehicle plate
      • capacity (number): Vehicle capacity
      • vehicleType (string): Vehicle type
  • token (string): JWT token

Example:

{
  "email": "jane.doe@example.com",
  "token": "jwt-token"
}

/captain/profile Endpoint

Description

This endpoint is used to get the profile of the authenticated captain.

HTTP Method

GET

Endpoint

/captain/profile

Example response

  • captain: (object):
    • fullname: (object):
      • firstname (string): Captain's first name
      • lastname (string): Captain's last name
    • email (string): Captain's email address
    • vehicle: (object):
      • color (string): Vehicle color
      • plate (string): Vehicle plate
      • capacity (number): Vehicle capacity
      • vehicleType (string): Vehicle type

Example:

{
  "fullname": {
    "firstname": "Jane",
    "lastname": "Doe"
  },
  "email": "jane.doe@example.com",
  "vehicle": {
    "color": "red",
    "plate": "ABC123",
    "capacity": 4,
    "vehicleType": "car"
  }
}

/captain/logout Endpoint

Description

This endpoint is used to log out the authenticated captain.

HTTP Method

POST

Endpoint

/captain/logout

Example response

  • message (string): Confirmation message Example:
{
  "message": "Logged Out"
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages