We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c18294c commit ce16218Copy full SHA for ce16218
shatter-backend/api/index.ts
@@ -27,4 +27,14 @@ connectDB().catch((err) => {
27
console.error('Failed to connect to MongoDB:', err);
28
});
29
30
+app.use(async (req, res, next) => {
31
+ try {
32
+ await connectDB();
33
+ next();
34
+ } catch (error) {
35
+ console.error('Database connection error:', error);
36
+ res.status(500).json({ error: 'Database connection failed' });
37
+ }
38
+});
39
+
40
export default app;
0 commit comments