This is a To-Do application built using Golang, HTML, CSS, and JavaScript. The backend is powered by the Fiber framework and a PostgreSQL database.
- User authentication (sign-up and log-in)
- Task creation, updating, deletion
- Task status updates
- Task filtering by status
- Retrieve details of individual tasks
- Endpoint:
POST /signup
- Description: Register a new user.
- Request Body:
{ "username": "string", "password": "string" }
- Response:
{ "message": "User created successfully." }
- Endpoint:
POST /login
- Description: Authenticate a user and return a token.
- Request Body:
{ "username": "string", "password": "string" }
- Response:
{ "token": "jwt_token" }
- Endpoint:
GET /users/{userId}
- Description: Retrieve user details by user ID.
- Request Headers:
Authorization: Bearer jwt_token
- Response:
{ "userId": "integer", "username": "string" }
- Endpoint:
POST /tasks
- Description: Create a new task.
- Request Headers:
Authorization: Bearer jwt_token
- Request Body:
{ "title": "string", "description": "string", "status": "string" // e.g., "pending", "completed" }
- Response:
{ "taskId": "integer", "message": "Task created successfully." }
- Endpoint:
PUT /tasks/{taskId}
- Description: Update an existing task.
- Request Headers:
Authorization: Bearer jwt_token
- Request Body:
{ "title": "string", "description": "string", "status": "string" // e.g., "pending", "completed" }
- Response:
{ "message": "Task updated successfully." }
- Endpoint:
DELETE /tasks/{taskId}
- Description: Delete a task by task ID.
- Request Headers:
Authorization: Bearer jwt_token
- Response:
{ "message": "Task deleted successfully." }
- Endpoint:
GET /tasks
- Description: Retrieve a list of tasks with optional filters.
- Request Headers:
Authorization: Bearer jwt_token
- Request Parameters:
status
(optional): Filter tasks by status (e.g.,pending
,completed
).
- Response:
{ "tasks": [ { "taskId": "integer", "title": "string", "description": "string", "status": "string", "createdAt": "datetime", "updatedAt": "datetime" }, ... ] }
- Endpoint:
GET /tasks/{taskId}
- Description: Retrieve details of a specific task by task ID.
- Request Headers:
Authorization: Bearer jwt_token
- Response:
{ "taskId": "integer", "title": "string", "description": "string", "status": "string", "createdAt": "datetime", "updatedAt": "datetime" }
- Go 1.16 or later
- PostgreSQL
- Fiber framework
- HTML, CSS, JavaScript
-
Clone the repository:
git clone https://github.com/yourusername/todo-app.git cd todo-app
-
Install dependencies:
go get -u github.com/gofiber/fiber/v2 go get -u github.com/gofiber/template/html/v2 go get -u github.com/lib/pq
-
Set up the PostgreSQL database and update the connection string in the code:
postgresql://<username>:<password>@<address>/<database_name>?sslmode=disable
-
Run the application:
go run server.go
Access the application at http://localhost:3000.