Skip to content
A rails API to create, update, delete and edit a list of tasks
Ruby HTML
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bin
config
db
lib/tasks
public
spec
storage
vendor
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
config.ru

README.md

todos-api

A rails API to create, update, delete and edit a list of tasks

rails new todos-api --api -T

NOTES

  • --api
    • tells rails we only want to create an API application
  • -T
    • excludes Minitest, default testing framework

Gems used in this project

  • rspec-rails - Testing framework.
  • factory_bot_rails - A fixtures replacement with a more straightforward syntax. You'll see.
  • shoulda_matchers - Provides RSpec with additional matchers.
  • database_cleaner - You guessed it! It literally cleans our test database to ensure a clean state in each test suite.
  • faker - A library for generating fake data. We'll use this to generate test data.

API will expose the following endpoints

Endpoint Functionality
POST/ signup Signup
POST /auth/login Login
GET /auth/logout Logout
GET /todos List all todos
POST /todos Create a new todo
GET /todos/:id Get a todo
PUT /todos/:id Update a todo
DELETE /todos/:id Delete a todo and its items
GET /todos/:id/items Get a todo item
PUT /todos/:id/items Update a todo item
DELETE /todos/:id/items Delete a todo item

Versioning API

  1. add route contstraint: will select version based on request headers
  2. Namespace the controllers: have diff contrller namespaces to handle different versions
  • Content Negotiation

    • REST closely tied to the HTTP specification
    • HTTP defined mechanisms, that make it possible to server different versions(represenations) of a resource
      • at the same URI
  • Vendor Tree

    • can define own media types using vendor tree specification

Serializers

  • allow for custom representation of JSON responses
  • active model serializers
    • make it easy to define which model attributes and relationships need to be serialized
  • In order to get todos with their respective items
    • we need to define serializers on the Todo model to include its attributes and relationships.

Pagination

  • make sure requests are still fast and optimized
You can’t perform that action at this time.