My suggestion, if you are still using const XXX = require('library or path./') when using module.exports to export multiple functions use an ES6 arrow function
for example:
module.exports = () => {
const getPosts = (req, res ) =>{
res.send('THIS WORKS!');
}
const getPost = async (req, res) => {
const { id } = req.params;
try {
const post = await PostMessage.findById(id);
res.status(200).json(post);
} catch (error) {
res.status(404).json({ message: error.message });
}
}
}
then Import: const getPosts = require('../controllers/posts.js');
Hope this helps... Cheers! www.miyamotto.net