code: function createExpressSubApp(rootApp, registry) {
      var express = require('express');
      var app = express();
      var viewEngine = CompiledEngine;
      if (debug.enabled) try {
          viewEngine = require('jade').__express;
      } catch (ex) {}
      app.engine('jade', viewEngine);
      app.set('view engine', 'jade');
      app.set('views', path.join(__dirname, '..', 'views'));
      app.locals.pretty = true;
      app.locals.version = registry.version;
  
      var cookieMiddleware = _(rootApp.stack).pluck('handle').find(function (handle) {
          return ~handle.name.search(/cookie/i);
      });
      if (!cookieMiddleware) {
          cookieMiddleware = require('cookie-session')({keys: [registry.title + '1234!@#$contact'], maxAge: 14 * 24 * 60 * 60});
          app.use(cookieMiddleware);
      }
      registerSockets(registry, cookieMiddleware);
  
      app.use('/vendor/ckeditor', statics(ckeditorPath));
      app.use(statics(path.join(__dirname, '..', 'assets')));
      app.use(bodyParser.urlencoded({extended: true}));
      app.use(bodyParser.json());
      app.use(function (err, req, res, next) {
          debug(err.stack);
          try {
              return res.send(500, err);
          } catch (e) {
              debug('cant send 500');
              debug(e.stack);
              err = e;
          }
          next(err);
      });
      return app;
  }
docs: End voodoo