fix: Resolve TypeError by correcting module dependency injection

This commit fixes a TypeError that occurred because the contactRoutes
module was being initialized before the contactController module.

The fix involves:
- Swapping the initialization order in server.js so the contactController is
  initialized before contactRoutes.
- Modifying contactRoutes.js to accept the initialized contactController
  as a dependency, rather than requiring it on its own.
This commit is contained in:
2025-08-17 17:59:44 -05:00
parent 562d831ddf
commit 0b48a79bec
2 changed files with 47 additions and 41 deletions

View File

@@ -34,10 +34,11 @@ const transporter = nodemailer.createTransport({
},
});
// Import contactRoutes and contactController
const contactRoutes = require('./routes/contactRoutes');
const contactController = require('./controllers/contactController')(pool, transporter);
// Import contactRoutes and contactController
const contactRoutes = require('./routes/contactRoutes')(contactController);
// Use contactRoutes to connect the modular router to the main app
app.use(contactRoutes);