Hi Jonia,
From the above code, I noticed that you are connecting to mongoDB using MongoClient but you are making requests to mongoDB using mongoose. This is the reason due to which at the time of startup you app is able to connect to mongoDB but when an API call is made then it throws timed out error because then you have not configured your mongoose to connect to the mongoDB.
Here is a sample snippet of how you can connect your mongoose to MongoDB
mongoose.connect(mongoURI, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => console.log('MongoDB connected successfully via Mongoose'))
.catch(err => {
console.error('Error connecting to MongoDB:', err);
process.exit(1);
});