Skip to content

nicehorse06/todo-list-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todo List API

This project is a simple RESTful API for managing a Todo List built using Golang, Gin, and a global in-memory store (which can be later replaced with Postgres or Redis).

Installation

If you are new to the project, follow these steps to set up the environment and install the necessary dependencies.

Prerequisites

Setup Instructions

  1. Clone the repository Clone the project from GitHub:

    git clone [email protected]:nicehorse06/todo-list-api.git
    cd todo-list-api
  2. Initialize the Go module Ensure the project is using Go modules. Run the following command to initialize Go modules if it hasn't been done yet:

    go mod init github.com/nicehorse06/todo-list-api
  3. Install dependencies Use go get to install all required dependencies for this project, including the Gin framework and testing libraries:

    go get -u github.com/gin-gonic/gin
    go get -u github.com/stretchr/testify/assert

    Alternatively, if the go.mod file is present, run the following to install dependencies:

    go mod tidy
  4. Run the application After installing dependencies, you can run the project with the following command:

    go run main.go
  5. Run the tests To run the test cases and ensure everything is working properly, execute:

    go test -v

go CLI Commands

Here are some useful Go CLI commands to work with the project.

Run the API server

Use the following command to start the API server:

go run main.go

This will start the server at localhost:8080, and you can access the endpoints such as http://localhost:8080/tasks.

Run the tests

Use the following command to run all the test cases:

go test -v

The -v flag provides verbose output, showing detailed information for each test case.

Endpoints

The following endpoints are available:

  1. Create a Task

    • POST /tasks
    • Body parameters: title, description, due_date
    • Response: Returns the created task details
  2. Get All Tasks

    • GET /tasks
    • Response: Returns a list of all tasks
  3. Get a Single Task

    • GET /tasks/:id
    • Parameters: id (the task ID)
    • Response: Returns the task details by its ID
  4. Update a Task

    • PUT /tasks/:id
    • Parameters: id (the task ID)
    • Body parameters: title, description, status
    • Response: Returns the updated task details
  5. Delete a Task

    • DELETE /tasks/:id
    • Parameters: id (the task ID)
    • Response: Deletes the task and returns a success message
  6. Mark Task as Complete

    • PATCH /tasks/:id/complete
    • Parameters: id (the task ID)
    • Response: Marks the task as complete and returns the updated task details

About

A simple RESTful Todo List API built with Golang.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages