☮ 20 Jun 2009
This week I wrote up a basic sinatra app that allows you to work with the Shopify API. It’s basically just a port of the shopify_app rails plugin to sinatra.
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.
The fastest way to get this thing running:
git clone git://github.com/jstorimer/sinatra-shopifycd sinatra-shopifyheroku create (make sure that you remember the name of your app as you will need that later)git push heroku masterheroku openThe current implementation for authentication is to add the authorize! method at the top of any routes that you want to be authenticated, like so:
http://github.com/jstorimer/sinatra-shopify
I am by no means a sinatra expert, this is really my first experience with sinatra. So if you see anything that could be done better, the source is on Github, fork away.