Skip to content

Instantly share code, notes, and snippets.

@bcoe
Created May 11, 2014 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcoe/f079e8880da570549715 to your computer and use it in GitHub Desktop.
Save bcoe/f079e8880da570549715 to your computer and use it in GitHub Desktop.
server.js
var restify = require('restify'),
server = restify.createServer(),
search = new (require('./lib').Search);
// add the query-string parsing extension
// to restify.
server.use(restify.queryParser());
// lookup packages by their name.
server.get('/search', function(req, res, cb) {
search.search(req.params.q, function(err, results) {
res.send(results);
cb();
});
});
// serve static JavaScript and CSS.
server.get(/\/js|css|images\/?.*/, restify.serveStatic({
directory: './assets'
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment