Skip to content

Instantly share code, notes, and snippets.

@troygoode
Created December 16, 2014 02:36
Show Gist options
  • Save troygoode/57ecb59384df014ed927 to your computer and use it in GitHub Desktop.
Save troygoode/57ecb59384df014ed927 to your computer and use it in GitHub Desktop.
router.get('/', function (req, res, next) {
// maybe validate that some filter criteria are sent?
debug('QUERY', req.query.q);
if (!req.query.q || req.query.q.length < 3) {
return next(new Error("'q' must be three or more characters"));
}
var results = Leads.search(req.query.q || '').then(function (results) {
debug('number of leads: ' + results.length);
res.json(results);
}).catch(next);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment