OpenShift Cartridge to get you started with Spark.js

I have spent a bit of time fig­ur­ing out how to get spark.js, node.js and Open­Shift all work­ing togeth­er and if you have read the last two post you may have seen some of the progress. Recent­ly I have cre­at­ed a car­tridge for Open­Shift, com­bin­ing every­thing into a rel­a­tive­ly easy to use pack­age. I hope it can save some­one some time and get their spark.io devices up and report­ing on the web faster!

Syn­op­sis (If you are in a hur­ry):

  1. Cre­ate Open­Shift Account: https://openshift.redhat.com
  2. Add a new appli­ca­tion and paste http://cdk-hippreality.rhcloud.com/manifest/9a1945721358ad2b20e7fd8c41f396ca2981014a into Code Any­thing input field.
  3. After com­plet­ing the forms and build­ing the appli­ca­tion, click through the appli­ca­tion, log in to Spark and see your devices and details list­ed in the web­site.

First, there are a ton of resources I need to thank for putting this togeth­er. Open­Shift and the car­tridge devel­op­ment kit (CDK) were a great start­ing point. The spark.js repo was an awe­some source of infor­ma­tion, along with the jade, node.js, express and the spark.io sites. Now, the good stuff!

First, if you do not have an Open­Shift account, you can cre­ate one for free here: https://openshift.redhat.com . Sign up, wait for an email and log in.

Once you are in, you can cre­ate a new appli­ca­tion by click­ing on the but­ton and you will see all of the great car­tridges already avail­able. How­ev­er, instead of select­ing one of them, scroll down to the “Code Any­thing” area and paste in this link to the cus­tom car­tridge: http://cdk-hippreality.rhcloud.com/manifest/9a1945721358ad2b20e7fd8c41f396ca2981014a

Once you hit next, it will ask you for a domain name and the name of the appli­ca­tion you are cre­at­ing. Once you have filled those in, you can scroll down to “Cre­ate Appli­ca­tion” and when you hit the but­ton it will build the site for you.

After the install com­pletes you will be able to see a list of your appli­ca­tions and when you click on the one you just cre­at­ed it will pro­vide you a link to the name of the appli­ca­tion and domain you select­ed ear­li­er. If you click on the link, you will see all of the parts from the pre­vi­ous posts run­ning in a sim­ple page. Just two lines of text and a but­ton.

Click on “Login to Spark” and put in your spark.io cre­den­tials and you will be sent to a page giv­ing you infor­ma­tion about your devices! This is just a start­ing point, using the frame­work you can cre­ate your own pages, but­tons and inter­ac­tions with your devices, which will be avail­able through this site!

If you want to start cus­tomiz­ing the page, use the link pro­vid­ed in your appli­ca­tion to clone your git local­ly and start build­ing your web appli­ca­tion! For sim­ple changes, to make sure every­thing is work­ing, you can edit routes/index.js title to reflect your own page infor­ma­tion. From here, your imag­i­na­tion is the only limitation…that and time!

Resources

For more infor­ma­tion relat­ed to Open­Shift and Node.js, refer to my last two posts. Good Luck!

Leave a Reply