Here, User is registerd and then can add,update,delete and get the tasks.
Before you begin, ensure you have the following dependencies installed:
- Node.js (with npm)
- PostgreSQL (for the database)
-
Clone the repository:
git clone https://github.com/RimshaBibi/user-tasks.git cd typescript -
Install Node.js dependencies:
npm install
-
Create a PostgreSQL database and configure the connection in your .env file. Set the following environment variables:
mailPassword=you_mail_password dbUser=your_db_user dbPassword=your_db_password host=your_db_host
-
Run the TypeScript build process and start the server:
npm run start
- POST /signup
- Description: Register a new user with a unique email.
- Request Body:
userName(string, required): User's name.userEmail(string, required, format: email): User's email address.userPassword(string, required): User's password.
- Response:
- 201 (Created): User registration successful.
user_id(string): Unique user identifier.name(string): User's name.email(string): User's email.salt(string): Salt used for password hashing.user_password(string): Hashed password.status(string): Status of account initially pending-approval.createddate(string): Date when account created.
- 409 (Conflict): User with the provided email already exists.
- 500 (Internal Server Error): Registration failed due to an internal error.
- 201 (Created): User registration successful.
- POST /signin
- Description: Authenticate a user.
- Request Body:
userEmail(string, required, format: email): User's email address.userPassword(string, required): User's password.
- Response:
- 200 (OK): User authentication successful.
user_id(string): Unique user identifier.email(string): User's email.user_password(string): Hashed password.salt(string): Salt used for password hashing.
- 404 (Unauthorized): User does not exist.
- 401 (Unauthorized): Wrong password.
- 500 (Internal Server Error): Authentication failed due to an internal error.
- 200 (OK): User authentication successful.
- POST /auth/refresh-token
- Description: Generating new jwt token from the expire token.
- Request Body:
token(string, required): Expire jwt token.user_id(string): Unique user identifier.userEmail(string, required, format: email): User's email address.
- Response:
- 201 (Created): New Jwt token generated successfully.
token(string): New jwt token.
- 404 (Not Found): User does not exist.
- 401 (Unathorized): Invalid token.
- 500 (Internal Server Error): An internal server error occurred while processing the request.
- 201 (Created): New Jwt token generated successfully.
- POST /addTask
- Description: Adding a task by the authenticated user.
- Request Headers:
authorization(string) : Authorization token is provided here.
- Request Body:
task_id(string) : Unique task identifier.title(string) : Title of the task.description(string) : Description of the task.user_id(string) : Unique user identifier.
- Response:
- 201 (Created): Task added successfully.
user_id(string): Unique user identifier.task_id(string): Unique task identifier.title(string): Title of the task.description(string): Description of the task.createddate(string): Date when the task created.
- 404 (Not Found): User does not exist.
- 500 (Internal Server Error): An internal server error occurred while processing the request.
- GET /getAllTasks
- Description: Authenticated user retrieve all tasks for all users.
- Request Headers:
authorization(string) : Authorization token is provided here.
- Request Query:
page(number) : Number of the page.size(number) : Number of the data shown.
- Response:
- 200 (OK): Successful retrieval of the tasks.
- Array of tasks, each with the following properties:
user_id(string): Unique user identifier.task_id(string): Unique task identifier.title(string): Title of the task.description(string): Description of the task.createddate(string): Date when task is created.updateddate(string): Date when task is updated.
- Array of tasks, each with the following properties:
- 400 (Invalid Request): Page and size are not available and page and size are not number.
- 404 (Not Found): No user exist and No task Found.
- 500 (Internal Server Error): An internal server error occurred while processing the request.
- GET /getOneTask/:task_id
- Description: Authenticated user retrieve one task by Id.
- Request Headers:
authorization(string) : Authorization token is provided here.
- URL Parameter:
-
task_id(string) : Unique task identifier. - Response:
- 200 (OK): Successful retrieval of the task.
user_id(string): Unique user identifier.task_id(string): Unique task identifier.title(string): Title of the task.description(string): Description of the task.createddate(string): Date when task is created.updateddate(string): Date when task is updated.
- 401 (Unathorized): Unauthorized user.
- 404 (Not Found): No user exist and No task Found.
- 500 (Internal Server Error): An internal server error occurred while processing the request.
- GET /getUserTasks
- Description: Authenticated user retrieve all his task.
- Request Headers:
authorization(string) : Authorization token is provided here.
- Request Query:
page(number) : Number of the page.size(number) : Number of the data shown.
- Response:
- 200 (OK): Successful retrieval of the tasks.
- Array of tasks, each with the following properties:
user_id(string): Unique user identifier.task_id(string): Unique task identifier.title(string): Title of the task.description(string): Description of the task.createddate(string): Date when task is created.updateddate(string): Date when task is updated.
- Array of tasks, each with the following properties:
- 400 (Invalid Request): Page and size are not available and page and size are not number.
- 404 (Not Found): No user exist and No task Found.
- 500 (Internal Server Error): An internal server error occurred while processing the request.
- PUT /updateTask/:task_id
- Description: Authenticated user updating task by Id.
- URL Parameter:
task_id(string) : Unique task identifier.
- Request Body:
title(string) : Title of the task.description(string) : Description of the task.
- Response:
- 200 (OK): Successfully updating task.
user_id(string): Unique user identifier.task_id(string): Unique task identifier.title(string): Title of the task.description(string): Description of the task.updateddate(string): Date when task updated.
- 400 (Unathorized): Task id is required.
- 401 (Unathorized): Unauthorized user.
- 404 (Not Found): No user exist and No task Found.
- 500 (Internal Server Error): An internal server error occurred while processing the request.
- DELETE /deleteTask/:task_id
- Description: Updating task by Id.
- URL Parameter:
task_id(string) : Unique task identifier.
- Response:
- 200 (OK): Successfully deleting the task.
- Response Body: A string indicating the success of the deletion.
- 400 (Unathorized): Task id is required.
- 401 (Unathorized): Unauthorized user.
- 404 (Not Found): No user exist and No task Found.
- 500 (Internal Server Error): An internal server error occurred while processing the request.
Contributions are welcome! Please follow these guidelines:
- Fork the repository.
- Create your feature branch:
git checkout -b <your_branch_name>
- Commit your changes:
git commit -m 'New feature added' - Push to the branch:
git push origin <your_branch_name>
- Open a pull request.
This project is licensed under the MIT License.
For questions or support, contact Rimsha Bibi on LinkedIn.