I'm having a strange issue, possabily a really noob one, but for the life of me I can't get node module.exports to work for me.
Here is my route (routes/about.js)
var About = (function () {
function About() {
this.init();
}
About.prototype.init = function () {
console.log('init');
};
About.prototype.me = function (req, res) {
this.init();
res.json([
'jamie was here'
]);
};
return About;
})();
module.exports = About;
and my app.js
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, about = require('./routes/about')
, http = require('http')
, path = require('path');
var app = express();
about = new about;
console.log(about);
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
app.get('/', routes.index);
app.get('/me/?', about.me);
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
When about.me is called, i get a "TypeError: Object # has no method 'init'" error...
Any help would be greatly appreciated!