Using kraken js middleware config to setup environment specific routes

Matt Edelman edited this page Apr 13, 2015 · 8 revisions
  • Define a module that exports a function that returns a router
//in path/to/controller
var express = require('express');

module.exports = function() {
  var router = express.Router();

  // path in `require`s below will be relative to this file
  router.get('/login', require('./path/to/loginMiddleware'));
  router.post('/login', require('./path/to/loginPostMiddleware'));
  router.get('/some/other/route', require('./path/to/otherRouteMiddleware'));

  return router;
}
  • Include the router module in <env>.json's middleware section
{
    "middleware": {
        "envRouter" : {
            "enabled" : true,
            "priority": 100 /*your appropriate priority*/,
            "module": {
                "name": "path:./path/to/controller"
            }
        }
    }
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.