import path from 'path';
import klm from 'koa-load-middlewares';

export default (app) => {
  let [config, ms, isProduction] = [app.config, klm(), Trek.isProduction];

  return {

    favicon: {
      handler: ms.favicon,
      options: path.join(config.publicPath, 'favicon.ico'),
      priority: 235
    },

    locale: {
      handler: ms.locale,
      options: app,
      isWrapped: true,
      priority: 240
    },

    i18n: {
      handler: ms.i18n,
      options: [app, config.get('i18n')],
      priority: 245
    },

    lusca: {
      handler: ms.lusca,
      options: config.get('lusca'),
      priority: 250
    },

    passport: {
      name: 'passport',
      handler: () => {
        let passport = ms.passport;
        app.use(passport.initialize());
        app.use(passport.session());
        app.cache.set('passport', passport);
      },
      isWrapped: true,
      priority: 255
    },

    connectFlash: {
      handler: ms.connectFlash,
      priority: 260
    },

    swig: {
      handler: ms.swig,
      options: [app, config.get('views')],
      isWrapped: true,
      priority: 265
    },

    router: {
      name: 'router',
      //disabled: true
    }
  };

};
@@ -161,16 +161,839 @@
 tion%5D;%0A%0A
+  /**%0A   * Installed middleware in Trek.%0A   * See %60trek/defaultStack.js%60%0A   *%0A   *  - logger%0A   *  - morgan%0A   *  - responseTime%0A   *  - xRequestId%0A   *  - staticCache%0A   *  - methodoverride%0A   *  - qs%0A   *  - bodyparser%0A   *  - compress%0A   *  - conditionalGet%0A   *  - etag%0A   *  - genericSession%0A   *  - router%0A   *%0A   * Below middlewares, install them if you need.%0A   *%0A   * %60%60%60%0A   *  middleware: %7B%0A   *    name: middlewareName%0A   *    handler: middlewareHandler,%0A   *    options: middlewareArguments,%0A   *    priority: 233,%0A   *    disabled: true,%0A   *    isWrapped: true%0A   *  %7D%0A   *  %60%60%60%0A   *%0A   *  * handler: middleware handler%0A   *  * options: middleware arguments%0A   *  * priority: middleware sort by priority%0A   *  * disabled: true    // disabled middleware%0A   *  * isWrapped: true   // likes: %60local(app)%60%0A   */%0A%0A
   return
@@ -996,16 +996,23 @@
 turn %7B%0A%0A
+    /*%0A
     favi
@@ -2008,16 +2008,23 @@
 e%0A    %7D%0A
+    */%0A
   %7D;%0A%0A%7D;

update comment