A simple Todo API built with Go. This project provides a backend service for a todo application, allowing users to manage projects and tasks. It uses the Echo web framework, connects to a PostgreSQL database, and integrates with Supabase for JWT-based authentication.
- Go: Version 1.22 or newer (Installation Guide)
- PostgreSQL: A running instance of PostgreSQL. (Download)
- Supabase Account: For authentication and obtaining a JWT signing key. (Supabase)
-
Clone the repository
git clone https://github.com/dmcleish91/go_todo_api.git cd go_todo_api
-
Setup environment variables
Create a
.env
file in the root directory of the project. You can copy the example below and fill in your details.# .env file # PostgreSQL connection details host=localhost port=5432 user=your_db_user password=your_db_password dbname=your_db_name # Supabase JWT signing key SUPABASE_JWT_SIGNINGKEY=your_supabase_jwt_signing_key
-
Set up the database
Connect to your PostgreSQL instance and run the table creation queries from the
queries.sql
file to set up the necessary tables (projects
andtasks
).
To run the application in development mode:
go run ./cmd/
The application should now be available at: http://localhost:1323
The project currently lacks a dedicated test suite. To run tests (once added):
go test ./...
To build a production binary:
# For Linux/macOS
go build -o todoapi ./cmd/
# For Windows
go build -o todoapi.exe ./cmd/
The executable will be created in the root directory.
- Add a comprehensive test suite (unit and integration tests).
- Refactor environment variable handling to use a struct.
- Implement more sophisticated input validation.
- Add swagger documentation for the API endpoints.
- Implement soft-delete for tasks and projects.
Tasks now have an order
integer field, which determines their position among sibling tasks (same project and parent_task_id). You can reorder tasks using the new endpoint:
PATCH /v1/tasks/reorder
Request Body:
[
{ "task_id": "a", "order": 0 },
{ "task_id": "b", "order": 1 },
...
]
- All tasks must belong to the authenticated user and have the same
project_id
andparent_task_id
. - The endpoint will update the order of these sibling tasks atomically.
- Fork the project.
- Create your feature branch (
git checkout -b feature/YourFeature
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/YourFeature
). - Open a Pull Request.