Skip to content

zedmakesense/simple-todo-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Todo API

A lightweight REST API for managing todos, built with Go and SQLite.

Features

  • Full CRUD operations (Create, Read, Update, Delete)
  • SQLite database for persistent storage
  • CORS enabled for cross-origin requests
  • Health check endpoint

Quick Start

# Install dependencies
go mod download

# Run the server
go run main.go

The server will start on http://localhost:8080 (or the port specified in PORT env variable).

API Endpoints

Method Endpoint Description
GET /todos List all todos
GET /todos/{id} Get a single todo
POST /todos Create a new todo
PATCH /todos/{id} Update a todo
DELETE /todos/{id} Delete a todo
GET /health Health check

Request/Response Examples

Create a todo

curl -X POST http://localhost:8080/todos \
  -H "Content-Type: application/json" \
  -d '{"text": "Buy groceries"}'

List all todos

curl http://localhost:8080/todos

Update a todo

curl -X PATCH http://localhost:8080/todos/1 \
  -H "Content-Type: application/json" \
  -d '{"done": true}'

Delete a todo

curl -X DELETE http://localhost:8080/todos/1

Configuration

Variable Default Description
PORT 8080 Server port

Create a .env file to override defaults:

PORT=3000

Tech Stack

  • Go 1.25+
  • SQLite (modernc.org/sqlite)
  • CORS (rs/cors)
  • godotenv

About

My first todo api.... YAY!

Topics

Resources

Stars

Watchers

Forks

Languages