Auth

POST /signup

Registers a new user.

Middleware

  • validateUserPhone(): Validates the phone number of the user.
  • validateUserFname(): Validates the first name of the user.
  • validateUserLname(): Validates the last name of the user.
  • validateUserPassword(): Validates the user's password.

Handler

  • register: Handles the registration process.

Request Body

json

{ "phone": "string", "fname": "string", "lname": "string", "password": "string" }

Response

  • 201 Created: User registered successfully.
  • 400 Bad Request: Validation error.
  • 500 Internal Server Error: Server error during registration.

POST /signin

Authenticates an existing user.

Middleware

  • validateUserPhone(): Validates the phone number of the user.
  • validateUserPassword(): Validates the user's password.

Handler

  • signin: Handles the authentication process.

Request Body

json

{ "phone": "string", "password": "string" }

Response

  • 200 OK: User signed in successfully, returns authentication token.
  • 400 Bad Request: Validation error.
  • 401 Unauthorized: Invalid credentials.
  • 500 Internal Server Error: Server error during authentication.

GET /protected

Accesses a protected route that requires authentication.

Middleware

  • validate: Validates the authentication token.

Response

  • 200 OK: Successfully accessed the protected resource.
  • 401 Unauthorized: Invalid or missing authentication token.
  • 500 Internal Server Error: Server error during validation.