Skip to content

Commit f1cd3ab

Browse files
committed
follow AI recommendations
1 parent 0cbcfd6 commit f1cd3ab

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

apps/server/src/index.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,12 @@ app.use(cors());
7070

7171
// Request timeout middleware
7272
app.use((req: Request, res: Response, next: NextFunction) => {
73-
req.setTimeout(30000, () => {
73+
res.setTimeout(30000, () => {
7474
res.status(408).json({ error: 'Request timeout' });
7575
});
7676
next();
7777
});
7878

79-
// Global error handling middleware
80-
app.use((error: Error, req: Request, res: Response, next: NextFunction) => {
81-
console.error('Unhandled error:', error);
82-
res.status(500).json({
83-
error: 'Internal server error',
84-
message: process.env.NODE_ENV === 'development' ? error.message : 'Something went wrong',
85-
});
86-
});
87-
88-
// 404 handler
89-
app.use('*', (req: Request, res: Response) => {
90-
res.status(404).json({ error: 'Route not found' });
91-
});
92-
9379
app.get('/', (_req, res) => {
9480
res.send('Server is running (v0.0.10)');
9581
});
@@ -575,6 +561,20 @@ app.post('/accounts/:accountAddress/inboxes/:inboxId/messages', async (req, res)
575561
broadcastAccountInboxMessage({ accountAddress, inboxId, message: createdMessage });
576562
});
577563

564+
// Global error handling middleware
565+
app.use((error: Error, req: Request, res: Response, next: NextFunction) => {
566+
console.error('Unhandled error:', error);
567+
res.status(500).json({
568+
error: 'Internal server error',
569+
message: process.env.NODE_ENV === 'development' ? error.message : 'Something went wrong',
570+
});
571+
});
572+
573+
// 404 handler
574+
app.use('*', (req: Request, res: Response) => {
575+
res.status(404).json({ error: 'Route not found' });
576+
});
577+
578578
const server = app.listen(PORT, () => {
579579
console.log(`Listening on port ${PORT}`);
580580
});

0 commit comments

Comments
 (0)