Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

Merge branch 'main' into feat-websockets-bugfixes

tiran13392e45b6adb7b
diff --cc apps/api/package.json
index fbe91515c,bdf02e67a..8d8dcc573
--- a/apps/api/package.json
+++ b/apps/api/package.json
@@@ -32,9 -32,9 +32,10 @@@
"@better-auth/api-key": "^1.5.6",
"@better-auth/drizzle-adapter": "^1.5.6",
"@hono/node-server": "^1.19.11",
+ "@hono/node-ws": "^1.3.0",
"@hono/standard-validator": "^0.2.2",
"@kaneo/email": "workspace:*",
+ "@modelcontextprotocol/sdk": "^1.26.0",
"@octokit/webhooks": "^14.2.0",
"@oslojs/crypto": "^1.0.1",
"@oslojs/encoding": "^1.1.0",
diff --cc apps/api/src/index.ts
index 4c7d3973b,db9e5c3b7..8b9bbe1bc
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@@ -486,58 -478,18 +496,68 @@@ export function createApp()
const invitationApi = api.route("/invitation", invitation);
const workspaceApi = api.route("/workspace", workspace);
+ app.route(
+ "/",
+ mcpWellKnownRoutes(
+ (process.env.KANEO_API_URL || "http://localhost:1337").replace(
+ /\/api\/?$/,
+ "",
+ ),
+ ),
+ );
+
app.route("/api", api);
+ app.get(
+ "/ws/:projectId",
+ upgradeWebSocket(async (c) => {
+ const projectId = c.req.param("projectId");
+
+ try {
+ await authenticateApiRequest(c);
+ } catch (error) {
+ if (error instanceof HTTPException) {
+ throw error;
+ }
+ console.error("API authentication failed:", error);
+ throw new HTTPException(500, { message: "Internal Server Error" });
+ }
+
+ const userId = c.get("userId");
+
+ if (projectId) {
+ const [project] = await db
+ .select({ workspaceId: schema.projectTable.workspaceId })
+ .from(schema.projectTable)
+ .where(eq(schema.projectTable.id, projectId))
+ .limit(1);
+
+ if (!project) {
+ throw new HTTPException(401, { message: "Unauthorized" });
+ }
+
+ await validateWorkspaceAccess(userId, project.workspaceId);
+ }
+
+ const windowId = c.req.query("windowId");
+ const initiatorId = windowId ? `${userId}:${windowId}` : userId;
+ let conn: ReturnType<typeof addConnection> | null = null;
+
+ return {
+ onOpen(_evt, ws) {
+ if (projectId) {
+ conn = addConnection(projectId, ws, userId, initiatorId);
+ }
+ },
+ onClose() {
+ if (conn && projectId) {
+ removeConnection(projectId, conn);
+ }
+ },
+ };
+ }),
+ );
+
return {
app,
api,