Files
Jarvise-project/backend/src/routes/health.js
T
BlackAngelTV 32dd462be5 feat(backend): add authenticated API for projects and Jarvis chat
Introduce the user/project/message model, JWT authentication and an Ollama
relay that streams answers chunk by chunk over SSE.
2026-10-05 15:01:57 +02:00

24 lines
538 B
JavaScript

/**
* Service health (public): database state and Ollama connectivity.
* @param {import('fastify').FastifyInstance} fastify
*/
export async function healthRoutes(fastify) {
fastify.get('/health', async () => {
let database = 'ok';
try {
fastify.db.countUsers();
} catch {
database = 'error';
}
const ollama = await fastify.ollama.listModels();
return {
status: database === 'ok' ? 'ok' : 'degraded',
database,
ollama,
uptime: Math.round(process.uptime()),
};
});
}