For the past three weeks I've been working on a new tool for Mozilla Webmaker. It is called the Make API. As Webmaker grows and more tools and more people create awesome content, we need a way to help them (and ourselves) share and organize this data efficiently. The Make API is being built to solve this problem.
This post will show you how to easily deploy the Make API to Heroku so you can start prototyping applications to consume and expose the data that it stores. Before that, I will give you a brief overview of what makes the API tick.
In the Make API, each project/resource/video remix etc. is defined as a "Make". Every record of a make will contain metadata that describes the Make, such as: type of make, creation date, author, etc. By indexing each record with Elastic Search, we can easily and efficiently retrieve records based on simple or complex search parameters.
Deploying to Heroku
To begin, you must have the following tools installed on your system:
- Git - http://git-scm.com/downloads
- Node.js and NPM - http://nodejs.org/
- Heroku toolbelt - https://toolbelt.heroku.com/
Once installed, get a terminal open, and navigate to the folder you with to download the Make API to and execute:
git clone git://github.com/mozilla/MakeAPI.git
And then "cd" into the cloned repository.
If you haven't already, authenticate with the Heroku API by running the following command and entering your credentials from your Heroku account:
You can now go ahead and run:
This command will add a remote to your cloned MakeAPI repository called Heroku that points to a newly provisioned Heroku app "space" (not sure what the real term is). It is given a randomly generated, and usually awesome name, but you can enter your own title by typing it in after
You must now set up some add-ons for your Heroku app.
These add-ons will enable basic MongoDB support and elastic search support. ( The providers offer free plans, which are limited in size and function. They are good enough for testing the app though. It is also unclear if the services will always be available. )
The Make API currently supports 4 different Heroku add-ons. You only need ONE of each type (MongoDB and Elastic Search)
For MongoDB you can choose between MongoLab and MongoHQ.
For Elastic Search you can choose between: Bonsai Elasticsearch or Found Elasticsearch.
To install a plugin for MongoDB run:
heroku addons:add mongohq:sandbox
heroku addons:add mongolab:starter
To install one of the Elastic Search add-ons run:
heroku addons:add bonsai
heroku addons:add foundelasticsearch:test
Heroku will automatically set up your environment variables for each plugin.
Now, push the master branch to Heroku:
git push heroku master
You will see some console output as Heroku processes the master branch and deploys it.
Once it finishes, you can visit the API test page by running:
and clicking on the link on the page that opens in your browser.
Server logs can be viewed by running:
PRO TIP:If you're working on a feature branch in git called "newFeature" you can push it to heroku for testing using the following syntax:
git push heroku newFeature:master