diff --git a/backend/src/index.ts b/backend/src/index.ts index af578ea..af5ae65 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -8,6 +8,7 @@ import extractRoutes from './routes/extract.js'; import exportRoutes from './routes/export.js'; import authRoutes from './routes/auth.js'; import paymentRoutes from './routes/payment.js'; +import healthRoutes from './routes/health.js'; dotenv.config(); @@ -32,6 +33,7 @@ app.use('/api/extract', extractRoutes); app.use('/api/export', exportRoutes); app.use('/api/auth', authRoutes); app.use('/api/payment', paymentRoutes); +app.use('/api/health', healthRoutes); app.listen(PORT, () => { console.log(`Server is running on port ${PORT}`); diff --git a/backend/src/routes/health.ts b/backend/src/routes/health.ts new file mode 100644 index 0000000..fcffdc9 --- /dev/null +++ b/backend/src/routes/health.ts @@ -0,0 +1,24 @@ +import { Router, Request, Response } from 'express'; + +const router = Router(); + +// Store server start time +const startTime = Date.now(); + +/** + * GET /api/health + * Health check endpoint for monitoring and setup verification + * Returns server status, uptime, and timestamp + */ +router.get('/', (req: Request, res: Response) => { + const now = new Date(); + const uptimeSeconds = Math.floor((Date.now() - startTime) / 1000); + + res.status(200).json({ + status: 'UP', + uptime: uptimeSeconds, + timestamp: now.toISOString(), + }); +}); + +export default router; \ No newline at end of file