wiki_thsf_2015/app.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2012-01-19 03:01:17 +11:00
var Express = require('express');
var Routes = require('./routes');
2012-01-18 16:09:31 +11:00
2012-01-19 03:01:17 +11:00
// var TryCatch = require('./trycatch');
//var App = module.exports = Express.createServer();
var App = Express();
2012-01-19 03:01:17 +11:00
// Configuration
App.configure(function(){
App.set('views', __dirname + '/views');
App.set('view engine', 'jade');
// This gives us scoped errors with long stack traces
// App.use(function (req, res, next) {
// TryCatch(next, next);
// });
App.use(Express.bodyParser());
App.use(Express.methodOverride());
App.use(App.router);
App.use(Express.static(__dirname + '/public'));
});
App.configure('development', function(){
App.use(Express.errorHandler({ dumpExceptions: true, showStack: true }));
});
App.configure('production', function(){
App.use(Express.errorHandler());
});
// Routes
App.get('/', Routes.index);
App.get('/:name', Routes.view);
App.get('/:name/edit', Routes.edit);
App.post('/:name', Routes.save);
server = App.listen(process.env.PORT || 3000);
console.log("Express server listening on port %d in %s mode", server.address().port, App.settings.env);