Skip to content

rafaelcamargo/kobbogo-api

Repository files navigation

Kobbogo API

An experimental API to dig deeper with Ruby on Rails.

CircleCI Coverage Status Ruby Style Guide

Contributing

  1. Install Ruby 3.x or greater - Prefer to install Ruby with Ruby Version Manager.

  2. Clone the repo:

git git@github.com:rafaelcamargo/kobbogo-api.git
  1. Go to the project directory
cd kobbogo-api
  1. Install the project dependencies
bundle install
  1. Create and setup databases - PostgreSQL 14.x (server 9.x) or greater:
rails db:create
rails db:migrate
  1. Serve the API:
rails s

The API will be running on http://localhost:3000.

Usage

User Collection

The User collection has a single endpoint. The endpoint requires username and a password to create an user:

Method URI Request Body Response Status Response Body
POST /users {
  username: String,
  password: String
}
201 (Created)

User Authentication

Authentication has a single endpoint. The endpoint requires user's credentials (username/password) and responds with a body containing a token, its expiration date (i.e. "06-19-2022 21:44"), and username:

Method URI Request Body Response Status Response Body
POST /auth {
  username: String,
  password: String
}
201 (Created) {
  token: String,
  exp: Date,
  username: String
}

Todo Collection

The Todo collection has three endpoints. All these endpoints need an Authentication token to be sent via request header. The header key must have the name Authorization and its value must be the token returned by the endpoint /auth.

Create

This endpoint requires a description to create a todo.

Method URI Request Body Response Status Response Body
POST /todos {
  description: String,
}
201 (Created) {
  id: UUID,
  description: String,
  created_at: Date,
  updated_at: Date,
}

Retrieve

This endpoint does not requires anything.

Method URI Request Body Response Status Response Body
GET /todos 200 (Ok) [{
  id: UUID,
  description: String,
  created_at: Date,
  updated_at: Date,
}]

Delete

This endpoint requires a todo id to be passed on the URI.

Method URI Request Body Response Status Response Body
DELETE /todos/:id 200 (Ok)

Code Format

Ensure that all the code you have added is properly formatted:

bundle exec rubocop

Tests

Ensure that all the code you have added is covered with automated tests:

bundle exec rspec

About

An experimental API to dig deeper on Ruby/Rails

Topics

Resources

Stars

Watchers

Forks