This is a backend service written in Golang along with PostgreSQL. The goal of this project is to let users manipulate a todo-list with RESTful API, including the functionalities below:
- Get all todo items.
- Get a specific todo item with ID.
- Create a todo item.
- Update a specific todo item with ID.
- Delete a specific todo item with ID.
- Go 1.20
- PostgreSQL 14.7
- (Optional) An operating system with Docker Engine
- Clone the repository.
- Execute
init.sql
within/database
folder in psql or pgAdmin to create table. - Run
go mod download
to download the dependencies. - Run
go run main.go
to start the service. - Access the application at
http://localhost:8080/todos
In the project root, run:
docker-compose up
The web application will be accessible at http://localhost:8080/todos
.
-
Content-Type:
application/json
Method Url Description GET /todos Get all todo items GET /todos/:id Get a specific todo item with ID POST /todos Create a todo item PUT /todos/:id Update a specific todo item with ID DELETE /todos/:id Delete a specific todo item with ID -
You can test APIs using software like Postman.
{
"title": "Title of the todo",
"description": "Description of the todo",
"completed": true or false
}
Other request do not need a request body.
- Timestamp of
created_at
andupdated_at
should beUTC(+8)
but isUTC(+0)
in Docker version.
- Error message (like accessing the id that does not exist) can be more accurate.
- Do not implement async/await.
- Do not use live reloading (like
nodemon
) when developing.
Currently has no license.