Skip to content

Instantly share code, notes, and snippets.

@austinyun
Created July 1, 2012 07:10
Show Gist options
  • Save austinyun/3027255 to your computer and use it in GitHub Desktop.
Save austinyun/3027255 to your computer and use it in GitHub Desktop.
Javascript killing the syntax file
var http = require('http'),
fs = require('fs'),
utils = require('util'),
git = require('git-fs'),
path = require('path'),
router = require('choreographer').router();
module.exports = function rice() {
// Initialize git-fs with the cwd
git(process.cwd());
router.get('/favicon.ico', function (req, res) {
fs.readFile('favicon.ico', function (err, icon) {
if (err) {
throw err;
}
res.writeHead(200, {
'Content-Type': 'image/x-icon';
});
res.end(icon);
});
});
router.get('/*', function (req, res) {
console.error("route hit");
git.readFile("fs", req.url, function (err, data) {
if (err) {
throw err;
}
console.log(data.toString());
res.end(data.toString());
});
});
router.notFound(function (req, res) {
res.writeHead(404, {
'Content-Type': 'text/plain'
});
res.end('Error 404: ' + req.url + ' not found.');
});
return http.createServer(router);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment