Boilerplate for a Ruby API.
This is just a concept.
Assuming the goal is to build a robust and reliable API that meets the standards of REST, this project is a boilerplate for your project.
The project was made with MySQL for the database, Sidekiq with Redis for running processes in the background and Rspec for running tests.
-
- You can create, read, find, update and delete products.
- Ruby >= 2.6.3
- MySQL >= 8
- Redis >= 5.0.5
- Copy
.env.sample, update with your information and rename it to.env. - Copy
config/database.yml.sample, update with your information and rename it todatabase.yml. - Install the dependencies by running:
$ bundle. - Setup the database by running:
$ rails db:create && rails db:migrate - Seed the development database. Run:
$ rails db:seed - Run rspec tests:
$ rails rspec - Start the server with
$ rails sand make sure Redis is running.
| HTTP Method | Path | Description | Params | HTTP Responses |
|---|---|---|---|---|
| POST | /auth |
Authentication sign in. | username:string required, password:string required | 200, 400, 401 |
| GET | /api/products |
Returns all products. | 200, 401 | |
| POST | /api/products |
Creates a new product. | name:string required, description:string | 201, 400, 401 |
| GET | /api/products/:id |
Returns a specific product. | 200, 401, 404 | |
| PATCH/PUT | /api/products/:id |
Updates a specific product. | name:string required, description:string | 200, 401, 404, 422 |
| DELETE | /api/products/:id |
Destroys a specific product. | 204, 401, 404 |
