switch to using and running *.coffee files instead of *.js as this is an app, not a package

This commit is contained in:
2012-03-15 00:00:44 +00:00
parent cc124d99f6
commit 8c1ebf8b91
10 changed files with 8 additions and 124 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.DS_Store
node_modules
docs
*.js

View File

@@ -2,22 +2,14 @@
.PHONY: build watch docs test deploy
BIN = ./node_modules/.bin
COFFEE_SRC = ./src
COFFEE_OUT = ./
REPORTER = spec
TEST_DIR = ./test
deploy:
git push heroku master
build:
$(BIN)/coffee -c -o $(COFFEE_OUT) $(COFFEE_SRC)
watch:
$(BIN)/coffee -cw -o $(COFFEE_OUT) $(COFFEE_SRC)
docs:
$(BIN)/docco $(shell find $(COFFEE_SRC) -name '*.coffee')
test:
$(BIN)/mocha -R $(REPORTER) $(TEST_DIR)/*.js
$(BIN)/mocha -R $(REPORTER) $(shell find $(TEST_DIR) -name '*.test.coffee')

View File

@@ -1 +1 @@
web: node heartbit.js
web: coffee server.coffee

View File

@@ -1,47 +0,0 @@
(function() {
var express, server;
express = require('express');
server = module.exports = express.createServer();
server.configure(function() {
server.set('views', __dirname + '/views');
server.set('view engine', 'coffee');
server.register('.coffee', require('coffeekup').adapters.express);
server.use(express.bodyParser());
server.use(express.methodOverride());
return server.use(express.static(__dirname + '/public'));
});
server.configure('development', function() {
return server.use(express.errorHandler({
dumpExceptions: true,
showStack: true
}));
});
server.configure('production', function() {
server.use(express.errorHandler());
return server.use(require('./middleware/host_redirect')({
"www.heartb.it": "http://heartb.it/"
}));
});
server.get('/', function(req, res) {
return res.render('index', {
format: true
});
});
server.get('*', function(req, res) {
return res.render('404', {
format: true
});
});
server.listen(process.env.PORT || 3000);
console.log("Express server listening on port %d in %s mode", server.address().port, server.settings.env);
}).call(this);

View File

@@ -1,16 +0,0 @@
(function() {
module.exports = function(redirect_map) {
if (redirect_map == null) redirect_map = {};
return function(req, res, next) {
var host;
host = req.header('Host');
if (redirect_map[host]) {
return res.redirect(redirect_map[host]);
} else {
return next();
}
};
};
}).call(this);

View File

@@ -11,5 +11,9 @@
"docco": "*",
"mocha": "*",
"should": "*"
},
"engine": {
"node": "0.6.x",
"npm": "1.x.x"
}
}

View File

@@ -1,50 +0,0 @@
(function() {
var host_redirect;
require('should');
host_redirect = require('../middleware/host_redirect');
describe('host_redirect', function() {
var redirect_map, redirector;
redirect_map = {
'www.foo.com': 'http://foo.com/',
'img.foo.com': 'http://images.foo.com/'
};
redirector = host_redirect(redirect_map);
describe('when request does not match any entry in map', function() {
return it('next() is called to pass on the request', function(done) {
var next, req, res;
req = {
header: function() {
return 'www.bar.com';
}
};
res = {};
next = function() {
return done();
};
return redirector(req, res, next);
});
});
return describe('when request matches an entry in map', function() {
return it('req.redirect() is called with the new URL', function(done) {
var next, req, res;
req = {
header: function() {
return 'img.foo.com';
}
};
res = {
redirect: function(url) {
url.should.equal(redirect_map[req.header()]);
return done();
}
};
next = function() {};
return redirector(req, res, next);
});
});
});
}).call(this);

View File

@@ -1,6 +1,6 @@
require 'should'
host_redirect = require '../middleware/host_redirect'
host_redirect = require '../../middleware/host_redirect'
describe 'host_redirect', ->