I am using v0.10.37 version of Node and 4.8 of Express. I'm trying to setup the route for the index. And the following errors appear
Error: Route.get () requires callback functions but got a [object Undefined]
Or:
Error: Can not find module './app/routes/home'
app / controller / home.js
module.exports = function() {
var controller = {};
index: function(req, res) {
res.render('index', {nome: 'Express'});
};
return controller;
};
app / routes / home.js
var controller = require('./app/controllers/home');
module.exports = function(app) {
app.get('/index', controller.index);
app.get('/', controller.index, function() {});
};
config / express.js
var express = require('express');
var home = require('./app/routes/home');
module.exports = function() {
var app = express();
app.set('port', 3000);
app.set('view engine', 'ejs');
app.set('views', './app/views');
//middleware
home(app);
return app;
};