Skip to content

Instantly share code, notes, and snippets.

@jeffdonthemic
Created April 27, 2012 11:23
Show Gist options
  • Save jeffdonthemic/2508501 to your computer and use it in GitHub Desktop.
Save jeffdonthemic/2508501 to your computer and use it in GitHub Desktop.
Force.com Node.js Demo - routes/index.js
// only needed if calling the rest api from this file (accounts route)
var rest = rest = require('./../rest.js');
/*
* GET home page.
*/
exports.index = function(req, res){
res.render('index', { title: 'Salesforce.com Node.js REST Demo' })
};
/*
* GET list of accounts - for larger apps, you may want to separate
* code into different routes for ease of maintenance and logic.
* Prevents app.js from becoming huge!
*/
exports.accounts = function(req, res){
rest.api(req).query("select id, name from account limit 10", function(data) {
res.render("accounts", { title: 'Accounts', data: data, user: req.session.identity } );
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment