#!/usr/bin/env node

var proxy = require('../lib/fiware-orion-pep'),
    config = require('../config');

proxy.start(function (error, proxyObj) {
    if (error) {
        process.exit();
    } else {
        var module;

        console.log('Loading middlewares');
        module = require('../' + config.middlewares.require);

        for (var i in config.middlewares.functions) {
            proxyObj.middlewares.push(module[config.middlewares.functions[i]]);
        }

        console.log('Server started');
    }
});
@@ -118,17 +118,16 @@
 function
- 
 (error, 
@@ -134,24 +134,41 @@
 proxyObj) %7B%0A
+    var module;%0A%0A
     if (erro
@@ -213,29 +213,8 @@
 e %7B%0A
-        var module;%0A%0A
     
@@ -509,8 +509,9 @@
    %7D%0A%7D);
+%0A

FIX Move the module definition to the top of the function