Git Product home page Git Product logo

riff's Introduction

Riff

Riff is a ruby gem that permits you to quickly build a Restful API in ruby projects that is using Roda and Sequel ORM.

Installation

Add this line to your application's Gemfile:

gem "riff", :git => "git://github.com/tomlobato/riff.git"

And then execute:

bundle install

Features

  • Auth (access_token/refresh_token)
  • Authorization
  • Parameters checking
  • Implementation of the default CRUD actions (but can be overwritten)
  • Custom actions (aka restful custom methods, like POST /actions/users/123:custom_method)
  • Pagination/Ordering
  • Request throttling (in the seed/sample_app)
  • [tests] Full test coverage

TODO

  • Rails and Activerecord support
  • JSON API support
  • Project generator (riff new my_api)
  • Gem docs
  • Docs generation for apis created with Riff
  • Elasticsearch support
  • rake to generate resource customizations from database tables
  • [marketing] Open source marketing

Usage

Instead to create a roda app from zero, copying the sample riff app is a quick way to have your project up and running.

But if you prefer to plug riff directly in you app...

  1. In your app.rb file (where you have class App < Roda ...), add entries like this to direct your requests to Riff (see the sample riff app).
route do |r|
  r.post('session', String) do |action|
    Riff.handle_session(r, response, action)
  end
  r.on('actions') do
    Riff.handle_action(r, response)
  end
end
  1. Create the riff customizations inside your app inside the constant path Actions::<MY_MODEL>::* for each model you want to expose in your api (see examples in sample_app/app/riff/actions).

  2. Configure Riff minimally setting the user class Riff::Conf.set(:default_auth_user_class, User), so riff can handle auth for you. See a example in riff.rb).

See also the sample_app and its specs for help on using Riff.

Running tests

The automated tests for riff are inside the sample_app:

cd sample_app

mysqladmin create my_app_test
# Then create .env.test based on .env.test.template

# Install and run redis-server in another terminal:
brew install redis # on mac
redis-server # on mac

sudo aptitude install redis-server # on ubuntu/debian

bundle install

RACK_ENV=test bundle exec rake db:migrate
RACK_ENV=test bundle exec rspec

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/tomlobato/riff. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Riff project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Acknowledgements

Riff runs on top of:

Big thanks to Jeremy Evans for bring to us Roda and Sequel, not mentioning rodauth and tons of other great code.

Big thanks to Mateusz Urbański for bring to us the great project todo_api, used in riff as a seed for the sample app and its auth logic for Riff auth handler.

riff's People

Contributors

mateuscmoura avatar tomlobato avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.