This is a basic Rails 4 application with Doorkeeper, Grape & Swagger for getting to API building quickly.
You can view the live app and the Swagger-ui documentation for developers.
Create .env file in the main folder of the project
SECRET_KEY_BASE=
DEVISE_SECRET_KEY=
DEFAULT_HOST=localhost:3000
EMAIL_ADDRESS=
EMAIL_PORT=
EMAIL_DOMAIN=
EMAIL_USER_NAME=
EMAIL_PASS=
EMAIL_AUTHENTICATION=
EMAIL_STARTTLS=
APP_API_DATABASE_USER=
APP_API_DATABASE_PASSWORD=
First bundle install
and rake db:setup
Run rake start
to get the server running locally. It runs at http://localhost:3001
Otherwise
Run rails s
to get the server running locally. It runs at http://localhost:3000
Grape is mounted in app/controllers/api, as described in the excellent Introduction to building APIs with Grape by Monterail, and part 2 of the series.
There are are other posts in the series which are worth reading, particularly OAuth Implicit Grant with Grape, Doorkeeper and AngularJS.
There is also a Railscast on doorkeeper.
Important things in the Gemfile:
- Doorkeeper (OAuth providing)
- grape (API building)
- wine_bouncer (Doorkeeper and Grape)
- grape-swagger (automatically generates Swagger docs for the auto documentation)
- Devise (users)
Also important, but maybe not as necessary to know about:
- rails_swagger-ui (how we get swagger-ui)
- Puma (the web server)
- api-pagination
- grape-active_model_serializers
- CORS
- foreman (in development to manage processes)
- Slim
- dotenv-rails (load environmental variables - .env is in .gitignore, so it isn't committed)
- Bootstrap
- Mysql
If you want to change the name of the app, swap out:
AppAPI
in config/application.rbapp-api
in config/database.yml (multiple instances)app-api
in config/initializers/session_store.rb
Rspec and guard - run bundle exec guard
to watch your spec files for changes and rerun tests for those files, otherwise if you prefer just run rspec