router integration issues due to closure scope... maybe #4
Description
Hey there, so I have been struggling to find a node template that works right off the bat with codeship. This one did the trick. But since the app.js is wrapped in a var app = function () {
trying to add within routes using var routes = require('./routes/routes');
and then app.use('/routes', routes);
does not work when in the routes.js file I try to use var router = express.Router();
and:
router.get('/', function(req, res, next) {
res.render('index', { title: "Codefish", header: "I've entered the Codeship!", paragraph: "I just deployed my Node.js app with Codeship" });
});
Similarly if I try to refactor the app.js and remove the var app = function () {
and inject into it the app.listen(...
from start.js and alter the package.json to "main": "app.js"
, that works locally, but when I run it through to codeship > heroku, node does not automatically load and so nothing gets served... Any idea why this might be the case? Would you have a refactored version that works with routes etc...? Thank you.