Advanced Node and Express - Clean Up Your Project with Modules

So my code seems to work fine but wouldn’t pass the test. I can’t seem to find where I have gone wrong. It seems like a pretty straight forward task to refractor into 2 separate classes and require them on the server.js but the test fails with “You should have required your new files”.

Any ideas why that may be?

my server.js:

'use strict';
const routes = require('./routes');
const auth = require('./auth');
const express       = require('express');
const bodyParser    = require('body-parser');
const fccTesting    = require('./freeCodeCamp/fcctesting.js');

// use session to store cookies for session, passport for authentication, mongodb for database
const session       = require('express-session');
const mongo         = require('mongodb').MongoClient;
  
const ObjectID      = require('mongodb').ObjectID;
const app = express();

app.set('view engine', 'pug');

fccTesting(app); //For FCC testing purposes
app.use('/public', express.static(process.cwd() + '/public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.use(session({
  secret: process.env.SESSION_SECRET,
  resave: true,
  saveUninitialized: true,
}));


if (process.env.ENABLE_DELAYS) app.use((req, res, next) => {
  switch (req.method) {
    case 'GET':
      switch (req.url) {
        case '/logout': console.log("logout ROUT"); return setTimeout(() => next(), 100);
        case '/profile': console.log("prof ROUT"); return setTimeout(() => next(), 200);
        default: next();
      }
    break;
    case 'POST':
      switch (req.url) {
        case '/login': console.log("login ROUT"); return setTimeout(() => next(), 1300);
        default: next();
      }
    break;
    default: next();
  }
});

mongo.connect(process.env.DATABASE, (err, db) => {
  if (err) {
    console.log('database error :'+err);
  }
  else {
    console.log("Connection succesful");
    auth(app, db);
    routes(app, db);
 
    app.use((req, res, next) => {
      res.status(404)
        .type('text')
        .send('Not Found');
    });

    app.listen(process.env.PORT || 3000, () => {
        console.log("Listening on port " + process.env.PORT);
    });
  }
//   db.collection('users').remove({}, (err, data) => {
  
//   });
}); 

this has been solved.
Although everything worked, but to pass the tests the require statements need to contain “.js” extension
like so…
const routes = require(’./routes.js’);
const auth = require(’./auth.js’);

@stevenYouhana Thanks for the code samples here and the work to figure this challenge out, I followed your example and still get an error:

Modules should be present.

I can’t figure out why I can’t pass this challenge. I’m wondering if you or someone else could check out my code on Glitch and point me in the right direction.

I’m getting the same error as well