Add healthcheck API (For uptimekuma, soon™️)
This commit is contained in:
parent
41748a040b
commit
06a324f9c4
13
index.js
13
index.js
|
@ -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
|
// Query to get a route
|
||||||
app.get('/api/v1/route/:apiKey/:ani/:number', (req, res) => {
|
app.get('/api/v1/route/:apiKey/:ani/:number', (req, res) => {
|
||||||
const apiKey = req.params.apiKey;
|
const apiKey = req.params.apiKey;
|
||||||
|
|
Loading…
Reference in a new issue