This is a monorepo of simple Todo API built with Go and Fiber with the frontend being built with React and TypeScript. It allows users to create, read, update, and delete todo items and have todo persistence using Mongo DB.
- Go 1.22.3 or later
- Git
- MongoDB
Clone the repository:
git clone https://github.com/nathanrydel/go-todo-app.git
cd go-todo-app
Install dependencies:
go mod tidy
Create a .env
file in the root directory and add the following lines:
PORT=8080
MONGODB_URI=your_mongodb_connection_string
Run the application using the Go command:
go run main.go
The server will start running at http://localhost:8080
.
- URL: /
- Method: GET
- Response:
{ "msg": "Hello, World!" }
- URL: /api/todos
- Method: GET
- Response: An array of todo objects
[ { "id": "60c72b2f9b1d8b3b5c8f9d9a", "completed": false, "body": "Sample todo" } ]
- URL: /api/todos
- Method: POST
- Request Body:
{ "body": "New todo item" }
- Response: The created todo object
{ "id": "60c72b2f9b1d8b3b5c8f9d9a", "completed": false, "body": "New todo item" }
- URL: /api/todos/:id
- Method: GET
- Response: The requested todo object
{ "id": "60c72b2f9b1d8b3b5c8f9d9a", "completed": false, "body": "Sample todo" }
- URL: /api/todos/:id
- Method: PATCH
- Request Body: One or both of the following fields
{ "completed": true, "body": "Updated todo item" }
- Response: The updated todo object
{ "id": "60c72b2f9b1d8b3b5c8f9d9a", "completed": true, "body": "Updated todo item" }
- URL: /api/todos/:id
- Method: DELETE
- Response:
{ "message": "Todo deleted" }
PORT
: The port number on which the server will run. This should be specified in a.env
file.MONGODB_URI
: The connection string for the MongoDB database.
- Fiber v2
- godotenv
- MongoDB Go Driver
This project is licensed under the MIT License. See the LICENSE file for details.
This project uses the following open-source packages:
- Fiber
- godotenv
- MongoDB Go Driver