Skip to content

Commit ce16218

Browse files
committed
fix async in index.js for deployment
1 parent c18294c commit ce16218

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

shatter-backend/api/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,14 @@ connectDB().catch((err) => {
2727
console.error('Failed to connect to MongoDB:', err);
2828
});
2929

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+
3040
export default app;

0 commit comments

Comments
 (0)