'use strict';

/*************************************************************
 * MIDDLEWARE
 ************************************************************/

module.exports.use = {
    poweredBy: require('./poweredBy'),
    compression: require('./compression'),
    livereload: require('./livereload'),
    viewEngine: require('./viewEngine'),
    logger: require('./logger'),
    favicon: require('./favicon'),
    bodyParser: require('./bodyParser'),
    cookieParser: require('./cookieParser'),
    session: require('./session'),
    passport: require('./passport'),
    flash: require('./flash'),
    expressStatic: require('./expressStatic'),
    expressLayouts: require('./expressLayouts'),
    appVariables: require('./appVariables'),
    routes: require('./routes'),
    locals: require('./locals'),
};

module.exports.order = [
    'poweredBy',
    'compression',
    'livereload',
    'viewEngine',
    'logger',
    'favicon',
    'bodyParser',
    'cookieParser',
    'session', //This must be before passport!!
    'passport',
    'flash',
    'expressStatic',
    'expressLayouts',
    'appVariables',
    'routes',
    'locals'
];

module.exports.dependencies = [
    'trackfinder',
    'compression',
    'serve-favicon',
    'body-parser',
    'cookie-parser',
    'passport',
    'express-session',
    'express-ejs-layouts',
    'morgan',
    'ejs',
    'express-flash-2'
];

@@ -152,26 +152,134 @@
 **/%0A
-%0Amodule.exports.us
+//TODO: Load all files in this dir that are not index.js%0A//TODO: Load all files in any passed source directory.%0A%0Alet middlewar
 e = 
@@ -629,24 +629,53 @@
 /session'),%0A
+    csrf: require('./csrf'),%0A
     passport
@@ -946,27 +946,21 @@
 ;%0A%0Am
-odule.exports.order
+iddleware.use
  = %5B
@@ -1176,16 +1176,28 @@
 flash',%0A
+    'csrf',%0A
     'exp
@@ -1287,21 +1287,17 @@
 ;%0A%0Am
-odule.exports
+iddleware
 .dep
@@ -1521,12 +1521,55 @@
 flash-2'
-%0A%5D
+,%0A    'csurf'%0A%5D;%0A%0Amodule.exports = middleware
 ;%0A

refactor how we expor module