https://github.com/rafaelcamargo/kobbogo-api
An experimental API to dig deeper on Ruby on Rails
https://github.com/rafaelcamargo/kobbogo-api
api-rest jwt-authentication rspec rubocop ruby-on-rails simplecov
Last synced: about 2 months ago
JSON representation
An experimental API to dig deeper on Ruby on Rails
- Host: GitHub
- URL: https://github.com/rafaelcamargo/kobbogo-api
- Owner: rafaelcamargo
- Created: 2021-11-22T13:10:19.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-12T16:21:38.000Z (over 2 years ago)
- Last Synced: 2025-02-15T20:49:23.239Z (4 months ago)
- Topics: api-rest, jwt-authentication, rspec, rubocop, ruby-on-rails, simplecov
- Language: Ruby
- Homepage: https://kobbogo-api.fly.dev/
- Size: 62.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kobbogo API
> An experimental API to dig deeper with Ruby on Rails.[](https://dl.circleci.com/status-badge/redirect/gh/rafaelcamargo/kobbogo-api/tree/master)
[](https://coveralls.io/github/rafaelcamargo/kobbogo-api?branch=master)
[](https://github.com/rubocop/rubocop)## Contributing
1. Install *Ruby 3.x or greater* - Prefer to install Ruby with [Ruby Version Manager](https://rvm.io/).
2. Clone the repo:
``` bash
git [email protected]:rafaelcamargo/kobbogo-api.git
```3. Go to the project directory
``` bash
cd kobbogo-api
```4. Install the project dependencies
``` bash
bundle install
```5. Create and setup databases - *[PostgreSQL](https://www.postgresql.org/) 14.x (server 9.x)* or greater:
``` bash
rails db:create
rails db:migrate
```6. Serve the API:
``` bash
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](https://www.httpstatuses.org/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](https://www.httpstatuses.org/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](https://www.httpstatuses.org/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](https://www.httpstatuses.org/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](https://www.httpstatuses.org/200) *(Ok)* | |## Code Format
Ensure that all the code you have added is [properly formatted](https://rubocop.org/):
``` bash
bundle exec rubocop
```## Tests
Ensure that all the code you have added is covered with [automated tests](https://rspec.info/):
``` bash
bundle exec rspec
```