This project is used for teaching students about JSON, HTTP and Restful APIs.
To run locally:
bundle
rake db:migrate
# With hot-reloading (recommended for development)
RACK_ENV=development rerun --pattern '{**/*.rb,**/*.ru,Gemfile,Gemfile.lock,Rakefile}' ruby app.rb
# Or without hot-reloading
ruby app.rbRuns on http://localhost:4567 by default.
Hot-reloading automatically restarts the server when code changes are made.
Use HTTPie (cleaner output than curl):
# Install if needed
brew install httpie
# Example requests
http GET http://localhost:4567/todos
http POST http://localhost:4567/todos title="Learn APIs" due="2025-12-31"
http GET http://localhost:4567/todos/1
http PATCH http://localhost:4567/todos/1 notes="Making progress"
http DELETE http://localhost:4567/todos/1Keep it minimal and simple. Always choose the simplest solution that achieves the goal. This is a teaching tool, not a production app.
GET /todos- List all todosPOST /todos- Create todo (requires: title, due; optional: notes)GET /todos/:id- Get single todoPATCH /todos/:id- Update todo (any fields)PUT /todos/:id- Full update (all fields required)DELETE /todos/:id- Delete todo
# Clear all todos
rake db:clear
# Seed database with sample todos
rake db:seed# Run tests (requires server running in another terminal)
rake # or
rake spec # or
bundle exec rspec# Run RuboCop to check for code issues
rake rubocop # or
bundle exec rubocop
# Auto-fix issues where possible
bundle exec rubocop -A