Skip to content

RootpathHQ/rp-todos-api

Repository files navigation

Rootpath Todos API

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.rb

Runs on http://localhost:4567 by default.

Hot-reloading automatically restarts the server when code changes are made.

Making Requests

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/1

Development Principles

Keep it minimal and simple. Always choose the simplest solution that achieves the goal. This is a teaching tool, not a production app.

API Endpoints

  • GET /todos - List all todos
  • POST /todos - Create todo (requires: title, due; optional: notes)
  • GET /todos/:id - Get single todo
  • PATCH /todos/:id - Update todo (any fields)
  • PUT /todos/:id - Full update (all fields required)
  • DELETE /todos/:id - Delete todo

Database Management

# Clear all todos
rake db:clear

# Seed database with sample todos
rake db:seed

Testing

# Run tests (requires server running in another terminal)
rake            # or
rake spec       # or
bundle exec rspec

Code Quality

# Run RuboCop to check for code issues
rake rubocop            # or
bundle exec rubocop

# Auto-fix issues where possible
bundle exec rubocop -A

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published