Add healthcheck API (For uptimekuma, soon™️)

This commit is contained in:
Christopher Cookman 2024-12-16 16:40:35 -07:00
parent 41748a040b
commit 06a324f9c4

View file

@ -596,6 +596,19 @@ app.get("/api/v1/checkAvailability/:number", (req, res) => {
});
});
app.get("/api/healthcheck", (req, res) => {
// Check ability to connect to database with select * from routes
db.get('SELECT * FROM routes', [], (err, row) => {
if (err) {
console.error('Error checking health:', err);
res.status(500).send('Internal server error');
return;
}
res.status(200).send('OK');
});
});
// Query to get a route
app.get('/api/v1/route/:apiKey/:ani/:number', (req, res) => {
const apiKey = req.params.apiKey;