Add 10-second health logger and /_cron/tick endpoint
This commit is contained in:
@@ -18,6 +18,21 @@ const apiRoot = config.apiPrefix || '/';
|
||||
app.use(apiRoot, createHealthRouter(config));
|
||||
app.use(apiRoot, createTodosRouter(config, db));
|
||||
|
||||
|
||||
// 10-second health check logger
|
||||
setInterval(() => {
|
||||
console.log('[Health Check] Sandbox is healthy at ' + new Date().toISOString());
|
||||
}, 10000);
|
||||
|
||||
app.post('/_cron/tick', (req, res) => {
|
||||
const authHeader = req.headers.authorization;
|
||||
if (!authHeader || authHeader !== 'Bearer ' + process.env.CRON_TOKEN) {
|
||||
return res.status(401).json({ success: false, error: 'Unauthorized' });
|
||||
}
|
||||
console.log('[Tick] Cloud Run cron tick triggered.');
|
||||
res.status(200).json({ success: true });
|
||||
});
|
||||
|
||||
app.use((_req, res) => {
|
||||
res.status(404).json({ success: false, error: 'Not found' });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user