Skip to content

AMar4enko/grape-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grape::Generate

Grape application template generator with batteries included

Getting started

First, install gem into your system

$ gem install 'grape-gen'

then grape-gen binary will be available in your shell. To generate default app skeleton, simply use:

$ grape-gen app your_app_name

After executing complete, dir your_app_name will be created in current dir.
Navigate into created dir and do $ bundle

Whats included?

  • carrierwave
  • sidekiq
  • faye
  • elastic search
  • redis

Grape API rack app

Rack app intended to be run under EventMachine-powered server (skeleton app using Thin)
Every library used is patched to play ball with EventMachine event loop.
To start web server:

$ RACK_ENV=production thin start -p 9292

Example webserver responding to following API methods:

  • POST /api/auth/register (display_name, email)
  • POST /api/auth/approve_email (email, email_approvement_code)
  • GET /api/profile
  • PUT /api/profile (avatar, remove_avatar, display_name)

/api/profile methods is restricted to use only by registered users.
API user must supply X-Authorize header, received from /api/auth/approve_email

When user approves email by calling POST /api/auth/approve_email with valid data,
message containing user display_name will be published into faye /user/registered channel
so all faye connections subscribed to /user/registered channel will receive info about newly registered user

Faye (optional, enabled by default)

Include faye support into skeleton app. To start faye server:

$ thin start -p 9393 -R faye.ru -e production

While running web server and faye server, please, visit http://localhost:9292/faye
Webpage contains simple implementation of faye client, connecting to localhost:9393 server
After successful connection client subscribes on two channels: /user/registered and /time
Faye events received displayed at the top of webpage

Sidekiq (optional, enabled by default)

Include support for background jobs via Sidekiq gem
Besides of main Sidekiq gem it also adds gem supporting jobs scheduling
Out of the box skeleton app have one scheduled job defined - /jobs/pong_time.rb
Job, scheduled to run each 5 seconds, simply publishes current time into /time faye channel so all faye connections subscribed to /time channel will receive current time string
For more information take a look at /config/sidekiq.yml

Mandrill (optional, enabled by default)

Include support for email delivery with Mandrill service via MandrillMailer gem.
To have this gem running you should add your Mandrill api key to /config/application.yml
After successful registration with POST /api/auth/register app tries to send message to user email using /mailers/registraion_mailer.rb
To have email delivered please make sure you have changed from address in /mailers/registraion_mailer.rb and appropriate domain name is registered for api key you add to config.file.

TODO

More documentation

Contributing

  1. Fork it ( https://github.com/AlexYankee/grape-gen/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Grape-powered rack application generator with batteries included

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published