Answer the question
In order to leave comments, you need to log in
Cannot read property 'handle' of undefined, why?
var express = require('express'),
http = require('http'),
path = require('path');
var config = require('./config/'),
log = require('./libs/log')(module);
var app = express();
app.set('views', __dirname + '/templates');
app.set('view engine', 'jade');
app.use(express.favicon());
if(app.get('env') == 'development') {
app.use(express.logger('dev'));
} else {
app.use(express.logger('default'));
}
app.use(express.bodyParser()); // req.body.....
app.use(express.cookieParser()); //req.cookies
app.use(express.router);
app.get('/', function(req, res, next) {
res.end('Test');
});
app.use(express.static(path.join(__dirname, 'public')));
////////////////////////////////////////////////////////
http.createServer(app).listen(config.get('port'), function() {
log.info('Express server listening on port ' + config.get('port'));
});
// Middleware
app.use(function(req, res) {
res.send(404, 'Page not found');
});
app.use(function(err, req, res, next) {
if(app.get('env') == 'development') {
var errorHandler = express.errorHandler();
errorHandler(err);
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question