Skip to content

dmcleish91/go_todo_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Todo API

Overview

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.

Getting Started

Prerequisites

  • 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)

Setup

  1. Clone the repository

    git clone https://github.com/dmcleish91/go_todo_api.git
    cd go_todo_api
  2. 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
  3. 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 and tasks).

Running the Development Server

To run the application in development mode:

go run ./cmd/

The application should now be available at: http://localhost:1323

Running Tests

The project currently lacks a dedicated test suite. To run tests (once added):

go test ./...

Building for Production

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.

Future Features / TODO

  • 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.

Task Ordering

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:

Reorder Tasks 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 and parent_task_id.
  • The endpoint will update the order of these sibling tasks atomically.

Contributing

  1. Fork the project.
  2. Create your feature branch (git checkout -b feature/YourFeature).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature/YourFeature).
  5. Open a Pull Request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages