/**
 * Server root
 *
 * Collects all routes and starts the server
 */
require('./evilGlobalVariables');

const glob = require('glob-promise');
const express = require('express');
const { partial } = require('lodash');
const bodyParser = require('body-parser');

const server = express();

/* Setup the application server */
server.use(bodyParser.json());

/* Building blocks */
const findRoutes = partial(glob, './src/routes/**/*.js');
const findMiddlewares = partial(glob, './src/middlewares/**/*.js');
const requireAndIntegrate = function(files, app) {
    files.forEach(file => {
        const fn = require(file);

        if ('function' === typeof fn) fn(app);
    });
};

/* Start ✨ */
findRoutes()
    .then(routes => {
        requireAndIntegrate(routes, server);
        return findMiddlewares();
    })
    .then(middlewares => {
        requireAndIntegrate(middlewares, server);
    })
    .then(function() {
        server.listen(3000);
    })
    .catch(reason => {
        console.error('Failed to start the server', reason);
    });

@@ -689,20 +689,25 @@
  */%0Afind
-Rout
+Middlewar
 es()%0A   
@@ -713,20 +713,25 @@
   .then(
-rout
+middlewar
 es =%3E %7B%0A
@@ -758,20 +758,25 @@
 tegrate(
-rout
+middlewar
 es, serv
@@ -795,33 +795,28 @@
  return find
-Middlewar
+Rout
 es();%0A    %7D)
@@ -822,33 +822,28 @@
 )%0A    .then(
-middlewar
+rout
 es =%3E %7B%0A    
@@ -862,33 +862,28 @@
 ndIntegrate(
-middlewar
+rout
 es, server);

Reorder the loading to make it work