https://signs-5n09.onrender.com
POST /auth/signup
Creates a new user account. Expects user input data in the request body and returns a success message with user details and a token.
- Content-Type:
application/json
{
"fullname": "string",
"email": "string",
"password": "string",
"role": "string"
}
- fullname (string): The full name of the user.
- email (string): The email address of the user. It should be unique and not already registered.
- password (string): The password for the user account. It will be hashed before storing.
- role (string): The role assigned to the user (e.g., "USER", "ADMIN").
curl -X POST https://signs-5n09.onrender.com/auth/signup \
-H "Content-Type: application/json" \
-d '{
"fullname": "John Doe",
"email": "[email protected]",
"password": "password123",
"role": "USER"
}'
200 OK
{
"status": "success",
"message": "user created successfully",
"data": {
"id": "number",
"fullname": "string",
"email": "string",
"userRole": "string"
},
"token": "string"
}
- status (string): Status of the response.
- message (string): A success message.
- data (object):
- id (number): The unique ID of the newly created user.
- fullname (string): The full name of the user.
- email (string): The email address of the user.
- userRole (string): The role assigned to the user.
- token (string): JWT token for authentication.
POST /auth/login
Logs in an existing user. Expects user email and password in the request body and returns a success message with user details and a token.
- Content-Type:
application/json
{
"email": "string",
"password": "string"
}
- email (string): The email address of the user.
- password (string): The password for the user account.
curl -X POST https://signs-5n09.onrender.com/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "password123"
}'
200 OK
{
"status": "success",
"message": "login successfully",
"data": {
"id": "number",
"fullname": "string",
"userRole": "string"
},
"token": "string"
}
- status (string): Status of the response.
- message (string): A success message.
- data (object):
- id (number): The unique ID of the logged-in user.
- fullname (string): The full name of the user.
- userRole (string): The role assigned to the user.
- token (string): JWT token for authentication.
POST /contact
send a contact us message
- Content-Type:
application/json
{
"email": "string",
"description": "string"
}
- email (string): The email address of the user.
- password (string): The description of your message.
curl -X POST https://signs-5n09.onrender.com/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "string",
"description": "string"
}'
200 OK
{
"status": true,
"message": "email sent successfully"
}
POST /sign
create a sign
- Content-Type:
application/json
| field name | value |
|----------|----------|
| text | HEllo testing |
| video | 'WIN_20240730_04_17_11_Pro.mp4' |
- text (string): The email address of the user.
- video (string): The video path.
200 OK
{
"status": true,
"message": "Sign created successfully",
"data": {
"text": "looking",
"videoUrl": "https://res.cloudinary.com/dhq33r9pa/video/upload/v1722311967/signs/videos/unhvow8fkbtg4fctbexq.mp4"
}
}
GET /sign/all
get all signs
200 OK
{
"status": true,
"message": "Sign fetched successfully",
"data": [
{
"text": "looking",
"videoUrl": "https://res.cloudinary.com/dhq33r9pa/video/upload/v1722310073/qzyegqkir6ahil8sd8oy.mp4"
},
{
"text": "looking",
"videoUrl": "https://res.cloudinary.com/dhq33r9pa/video/upload/v1722310514/signs/videos/nsia6tkx3auc4ynw9xh6.mov"
},
{
"text": "looking",
"videoUrl": "https://res.cloudinary.com/dhq33r9pa/video/upload/v1722311967/signs/videos/unhvow8fkbtg4fctbexq.mp4"
}
]
}
The ErrorHandler
class distinguishes between trusted errors (operational errors) and critical errors. It provides appropriate responses for trusted errors and handles critical errors by logging them and terminating the process.
Trusted errors are operational errors that the application expects and handles gracefully. They are typically instances of the AppError
class. For these errors, the API responds with the specific HTTP status code and error message provided by the AppError
instance.
HTTP Status Code: Defined by AppError
Content-Type: application/json
{
"status": "error",
"message": "Error message here"
}
- status (string): Indicates that there was an error.
- message (string): A descriptive error message for the client.
-
User Already Exists (Sign-Up)
- Status: 401 Unauthorized
- Body:
{ "status": "error", "message": "User already exists" }
-
User Does Not Exist (Login)
- Status: 401 Unauthorized
- Body:
{ "status": "error", "message": "User does not exist, Please sign up" }
-
Incorrect Password (Login)
- Status: 401 Unauthorized
- Body:
{ "status": "error", "message": "Password is incorrect, Please try again" }
Critical errors are unexpected errors that indicate a serious problem in the application. These errors are not handled through the API responses but are logged, and the process is terminated to avoid further issues.
HTTP Status Code: 500 Internal Server Error
Content-Type: application/json
{
"status": false,
"message": "Internal server error"
}
- status (boolean): Indicates that there was a critical error.
- message (string): A generic error message for the client.