This repository contains the backend code for the CASVAL project.
- Clone the repository:
git clone https://github.com/yourusername/casval_backend.git
- Navigate to the project directory:
cd casval_backend
- Install the dependencies:
npm install
- Create a
.env
file in the root directory and add your environment variables:touch .env
To start the server, run:
npm start
The server will be running on http://localhost:5001
.
-
Login
- URL:
/api/v1/login
- Method:
POST
- Description: Logs in a user.
- Body Parameters:
email
(string, required)password
(string, required)
- URL:
-
Register
- URL:
/api/v1/register
- Method:
POST
- Description: Registers a new user.
- Body Parameters:
email
(string, required)username
(string, required)password
(string, required)
- URL:
-
Get Current User
- URL:
/api/v1/me
- Method:
GET
- Description: Retrieves the current logged-in user's information.
- Headers:
Authorization
(string, required)
- URL:
-
Update Profile
- URL:
/api/v1/update-profile/:id
- Method:
PATCH
- Description: Updates the profile of the user.
- Headers:
Authorization
(string, required)
- Body Parameters:
nickname
(string, optional)password
(string, optional)
- URL:
-
Delete User
- URL:
/api/v1/delete-user/:id
- Method:
DELETE
- Description: Deletes a user.
- Headers:
Authorization
(string, required)
- URL:
-
Forget Password
- URL:
/api/v1/forget-password
- Method:
POST
- Description: Sends a password reset code to the user's email.
- Body Parameters:
email
(string, required)
- URL:
-
Reset Code Check
- URL:
/api/v1/reset-code-check
- Method:
POST
- Description: Checks the reset code sent to the user's email.
- Body Parameters:
email
(string, required)code
(string, required)
- URL:
-
Reset Password
- URL:
/api/v1/reset-password
- Method:
POST
- Description: Resets the user's password.
- Body Parameters:
password
(string, required)temporaryToken
(string, required)
- URL:
-
Get User by ID
- URL:
/api/v1/get-user/:id
- Method:
GET
- Description: Retrieves a user by their ID.
- Headers:
Authorization
(string, required)
- URL:
-
Get All Users
- URL:
/api/v1/get-users
- Method:
GET
- Description: Retrieves all users.
- Headers:
Authorization
(string, required)
- URL:
Errors are handled using a custom error handler middleware. The APIError
class is used to throw errors with specific status codes and messages.
This project is licensed under the ISC License.