Introduce the user/project/message model, JWT authentication and an Ollama relay that streams answers chunk by chunk over SSE.
24 lines
538 B
JavaScript
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()),
|
|
};
|
|
});
|
|
}
|