Created
May 11, 2014 18:22
-
-
Save bcoe/f079e8880da570549715 to your computer and use it in GitHub Desktop.
server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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