Using Node.js with Apex REST
To get Node.js up and running, I wouldn't go any farther than fellow evangelist James Ward's Getting Started with Node.js article. It's easily one of the most complete, starting from a blank slate where one hasn't tried git or Heroku before and takes you to creating a simple Hello World application using the popular Node module express.
I've started putting together a sample application which access our OAuth login and REST endpoints (similar in functionality to the Flex REST project). The most stable version will be updated over at our developerforce github account, under the rather unmarketable title of FDC-NODEJS-HEROKU. It might need a rebranding as "Black Falcon" or the like in the future, but at least there's little question about what resides there at the moment.
This project includes support for the new Apex REST endpoints, and is a great way to test out the new functionality. The demo project currently uses the Node.js server as a proxy for sending out AJAX calls using jQuery, so creating this callout
on the web page will be converted into a call to a custom endpoint "FieldCase" which has been defined completely using Apex REST. Using this call, all we need is a company name and a case type, and the code will create the correct case with the correct support persons and documentation. You can also call the rest module directly, if you want to blend these callouts with existing Node.js projects.
Apex REST is currently in pilot, so you'll need to contact Salesforce support – or as usual, send a tweet to @joshbirk and I'll see if I can get things enabled. It's a brilliant way to simplify your REST calls and allow for more complicated business processes with your application.
Honestly, there's too much to cover in just this blog post. In fact, we have a whole webinar coming up just on Apex REST itself on July 19th, so register now and bask in the Summer of API's. I'll have more on Node.js, REST and this project later as well.
Naturally, if you want to get the latest and greatest information on developing with Heroku and Force.com – head on over to Dreamforce, where you can meet with us face to face to learn cutting edge techniques with the platform.