An experimental API to dig deeper with Ruby on Rails.
-
Install Ruby 3.x or greater - Prefer to install Ruby with Ruby Version Manager.
-
Clone the repo:
git git@github.com:rafaelcamargo/kobbogo-api.git
- Go to the project directory
cd kobbogo-api
- Install the project dependencies
bundle install
- Create and setup databases - PostgreSQL 14.x (server 9.x) or greater:
rails db:create
rails db:migrate
- Serve the API:
rails s
The API will be running on http://localhost:3000
.
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) |
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 } |
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
.
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, } |
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, }] |
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) |
Ensure that all the code you have added is properly formatted:
bundle exec rubocop
Ensure that all the code you have added is covered with automated tests:
bundle exec rspec