curl --request GET \
--url https://api.example.com/api/health{
"status": "<string>",
"time": {}
}Check the health status of the MediGuide API and database connection
curl --request GET \
--url https://api.example.com/api/health{
"status": "<string>",
"time": {}
}GET /api/health
"ok" when the server and database are operational.curl http://localhost:3001/api/health
{
"status": "ok",
"time": {
"now": "2024-03-06T16:30:45.123Z"
}
}
{
"status": "error",
"error": "connection to database failed"
}
server.js:23-30:
app.get('/api/health', async (req, res) => {
try {
const { rows } = await pool.query('SELECT NOW()');
return res.json({ status: 'ok', time: rows[0] });
} catch (error) {
return res.status(500).json({ status: 'error', error: error.message });
}
});