Makelore 2.0 initial clean snapshot
This commit is contained in:
35
electron/api/routes/app.ts
Normal file
35
electron/api/routes/app.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import type { HostApiContext } from '../context';
|
||||
import { sendJson } from '../route-utils';
|
||||
|
||||
export async function handleAppRoutes(
|
||||
req: IncomingMessage,
|
||||
res: ServerResponse,
|
||||
url: URL,
|
||||
ctx: HostApiContext,
|
||||
): Promise<boolean> {
|
||||
if (url.pathname === '/api/events' && req.method === 'GET') {
|
||||
// CORS headers are already set by the server middleware.
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'text/event-stream; charset=utf-8',
|
||||
'Cache-Control': 'no-cache, no-transform',
|
||||
Connection: 'keep-alive',
|
||||
});
|
||||
res.write(': connected\n\n');
|
||||
ctx.eventBus.addSseClient(res);
|
||||
res.write(`event: opencode:status\ndata: ${JSON.stringify(ctx.opencodeManager.getStatus())}\n\n`);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (url.pathname === '/api/app/runtime-info' && req.method === 'GET') {
|
||||
sendJson(res, 200, {
|
||||
runtime: 'opencode',
|
||||
status: ctx.opencodeManager.getStatus(),
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// OPTIONS is handled by the server middleware; no route-level handler needed.
|
||||
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user