Skip to content

Instantly share code, notes, and snippets.

@grawk
Last active August 29, 2015 14:05
Show Gist options
  • Save grawk/2f237bfbdd2378aa6934 to your computer and use it in GitHub Desktop.
Save grawk/2f237bfbdd2378aa6934 to your computer and use it in GitHub Desktop.
discussion of kraken-examples routes

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

@grawk
Copy link
Author

grawk commented Aug 13, 2014

OK. good enough for me. let me fix all this and resubmit the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment