is this what you think routes/index.js
should look like:
'use strict';
var IndexModel = require('../models/index');
var setLocale = require('./setLocale');
module.exports = function (router) {
router.get('/', indexRoute);
setLocale(router);
};
function indexRoute(req, res) {
var model = new IndexModel();
res.render('index', model);
};
with routes/setLocale.js
:
'use strict';
module.exports = function (router) {
router.get('/setLocale/:locale', setLocale);
};
function setLocale(req, res) {
res.cookie('locale', req.params.locale);
res.redirect('/');
};
my understanding is that any module under the routes
directory should have a route
signature and the main routes file needs to register all these routes as i've done in index.js above
more like ...
routes/index.js
routes/setLocale.js