I have been having fun working on Shopify apps lately, but I needed a simpler way than always generating a new rails app, new controllers, etc., for every little idea.
Rails is great, but most of the Shopify apps that I have come up with are one page apps, maybe two or three pages. The point is, I don't need a controller for that, I don't need the 63 files or however many the rails generator generates for me.
Sinatra is most awesome when you are working on a small app with just a few routes. You can clone this app and use it as a starting point for a shopify_app. All of the authentication logic/routes are in the lib folder, so they don't pollute the code of your app.
So in app.rb, you just have to worry about the functionality of your app.
Installable from rubygems as
sinatra-shopify or you can add it to your gemfile as
The current implementation for authentication is to add the
authorize! method at the top of any routes that you want to be authenticated, like so:
get '/sensitive_data' do authorize! # then do the sensitive stuff end
This repo includes an example Sinatra app. The fastest way to get it running:
git clone git://github.com/jstorimer/sinatra-shopify
heroku create(make sure that you remember the name of your app as you will need that later)
- visit the Shopify Partners area
- Sign up for an account if you don't already have one
- Log in to your Shopify partners account
- Create a new application.
- Make sure that the Callback URL is set to
- In the
lib/sinatra/shopify.ymlfile replace API_KEY and SECRET with the Api Key and Secret that you just got from the Shopify Partners area
git push heroku master