This is a new api for restuarants, you can login, sign up and create resturants.
Do we need authentication, do we need token.
Sure, here's a Markdown documentation for the provided code:
This documentation outlines the endpoints and functionality of a user authentication API. The API allows users to sign up and log in as owners.
POST /signup
This endpoint allows a user to sign up as an owner by providing their name, email, and password. It checks if the email is unique, hashes the password for security, and creates a new owner in the system if all checks pass.
name(string): The name of the owner.email(string): The email address of the owner.password(string): The password for the owner's account.
-
HTTP Status Code: 201 Created
-
Response Body:
{ "message": "Owner created successfully", "owner": { // Owner object containing details } }
-
HTTP Status Code: 409 Conflict
{ "message": "Owner already exists" } -
HTTP Status Code: 500 Internal Server Error
{ "message": "Something went wrong", "error": "Error message details" }
POST /login
This endpoint allows a user to log in as an owner by providing their email and password. It verifies the email's existence, checks if the provided password matches the stored hashed password, and issues a JWT token for authenticated access.
email(string): The email address of the owner.password(string): The password for the owner's account.
-
HTTP Status Code: 200 OK
-
Response Body:
{ "message": "Owner logged in successfully", "token": "JWT Token" }
-
HTTP Status Code: 404 Not Found
{ "message": "Owner not found" } -
HTTP Status Code: 401 Unauthorized
{ "message": "Invalid credentials" } -
HTTP Status Code: 500 Internal Server Error
{ "message": "Something went wrong", "error": "Error message details" }