# README
Task Management API
A simple task management application helps to organize and prioritize teh tasks.
Task management API is an backend API service build using golang used to perform CRUD Operation to create a task, update it, read it and delete the tasks.
Local Development
Prerequisites
Before you begin, ensure you have the following installed:
-
Go (1.18 or later): Download Go
-
MYSQL: Database for storing tasks and user data. (This API uses MYSQL to store the task details)
-
cURL or Postman: For testing the API.
Steps
- Navigate to the project directory
git clone https://github.com/BharaniJ27/Task-Management-API.git cd Task-Management-API
- Install all the dependencies
go mod tidy
- Set up environment variables:
Create a
.env
file in the root of the project:PORT=3000 DB_PROTOCOL=tcp DB_USER=[DB_USER_NAME] DB_PASSWORD=[DB_PASSWORD] DB_NAME=[DB_NAME] DB_HOST=localhost DB_PORT=3306
- Initialize the database
CREATE DATABASE task_management; CREATE TABLE tasks ( id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(255) NOT NULL, description TEXT, status VARCHAR(255) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, deleted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON DELETE CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP );
- Run the application
CompileDaemon --build="go build -o main ./cmd" -command="./main"
- If faced any issue on step 5
go install github.com/githubnemo/CompileDaemon@latest echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.zshrc source ~/.zshrc
Testing
Create a task
Sample Payload
{
"Title": "Go Lang",
"Description": "Learn go lang",
"Status": "low"
}
Sample Response for task creation
{
"message": "Successfully created a task with id 1"
}
Update a task
Sample Payload
{
"Title": "Guitar",
"Description": "Learn go lang",
"Status": "medium"
}
Sample Response for task updation
{
"message": "Successfully updated a task 1"
}
Delete a task
Sample Request
Method: DELETE
http://localhost:3000/api/tasks/{taskID} - pass the task id the url
Sample Response for task deletion
{
"message": "Successfully deleted a task 5"
}