https://github.com/romerobrjp/punkapi
https://github.com/romerobrjp/punkapi
api-rest rails5 rails5-api ruby ruby-application ruby-on-rails rubyonrails
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/romerobrjp/punkapi
- Owner: romerobrjp
- Created: 2020-02-11T10:50:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-11T10:56:37.000Z (about 6 years ago)
- Last Synced: 2025-04-07T09:45:55.294Z (12 months ago)
- Topics: api-rest, rails5, rails5-api, ruby, ruby-application, ruby-on-rails, rubyonrails
- Language: Ruby
- Size: 57.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PUNK API
## Made with:
- ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
- rbenv 1.1.1-6-g2d7cefe
- Rails 5.1.4
## ER diagram
https://imgur.com/a/FPZ3H
## Tests
- FactoryBot instead of fixtures;
- Unit tests;
- Integration tests (request specs);
- I chose to work with requests specs instead of controllers specs due to the recommendation of the creators of Rails and RSpec, since it is a more comprehensive type of test, avoiding unnecessary granularization;
- I'm randomizing the tests order so that can be more robust. You can disable this feature by commenting the line `config.order = :random` at spec_helper.rb;
- I'm using the gem 'spring-commands-rspec' in order to increase the loading speed of the specs;
### How to run the tests
`bundle exec spring rspec`
Somehting like that should be displayed after running this command:
Finished in 2.28 seconds (files took 0.26843 seconds to load)
129 examples, 0 failures
Randomized with seed 49082
## How to run locally:
- Clone this repository
- `bundle install`
- `bundle exec rake db:create`
- `bundle exec rake db:migrate`
- Setup vars at .env file
- I recommend adding the following configuration to your hosts file (/etc/hosts in Linux) `0.0.0.0 punkapi.com`
- `rails s`
- `redis-server`
## Database
- I used PostgreSQL. Remember to edit the database params at .env file.
- You can execute the seeds if you want (seeds.rb)
## How to send requests to the API
- Base URL: http://punkapi.com:3000/v2
- For security reasons, you must send the Accept header with the following value: application/fractal.punk.v2
## Redis
- Don't forget to start the Redis server: opena another terminal window and run `redis-server`
## Etc
- API is versioned
- CORS is enabled
- Rate Limiting and Throttling configured