Skip to content

Using krakenjs middleware config for express subapps mounting

Poornima Venkat edited this page Apr 7, 2015 · 8 revisions
  • Defining a factory that returns a router
//in path/to/app
var express = require('express');

module.exports = function() {
  var app = express();

  //setup anything app specific

   // view engine

   // view paths

   // routes

   app.get('/login', require('./path/to/loginMiddleware'));
   app.post('/login', require('./path/to/loginPostMiddleware'));
   app.get('/some/other/route', require('./path/to/otherRouteMiddleware'));

   return app;
}
  • Including the factory on your middleware config in <env>.json
{
    "middleware": {
        "subapp" : {
            "enabled" : true,
            "priority": 100 /*your appropriate priority*/,
            "module": {
                "name": "path:./path/to/app"
            }
        }
    }
}