-
Notifications
You must be signed in to change notification settings - Fork 3.6k
refactor: live server #7720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: live server #7720
Changes from all commits
9999e86
e45815f
8be66c7
25cbd24
550bbe8
fc9ca0c
37cd162
e5a11cd
63b7b83
126b416
5830138
fe36d9a
f6dcc12
955ab39
47c9fc0
2322b77
b979465
465006b
3d455cc
eb1787b
483fb13
1941fff
2d568b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,13 +3,13 @@ | |
| "version": "1.0.0", | ||
| "license": "AGPL-3.0", | ||
| "description": "A realtime collaborative server powers Plane's rich text editor", | ||
| "main": "./src/server.ts", | ||
| "main": "./dist/start.js", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "tsdown", | ||
| "dev": "tsdown --watch", | ||
| "start": "node --env-file=.env dist/server.js", | ||
| "build": "tsc --noEmit && tsdown", | ||
| "dev": "tsdown --watch --onSuccess \"node --env-file=.env dist/start.js\"", | ||
| "start": "node --env-file=.env dist/start.js", | ||
|
Comment on lines
+10
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify Node.js version requirement is documented. The scripts use Run the following to confirm the engines field is present: 🏁 Script executed: #!/bin/bash
# Check if engines field exists in package.json
cat apps/live/package.json | jq -r '.engines'Length of output: 4 Add Node.js engine requirement in apps/live/package.json {
"engines": {
"node": ">=20.11.0"
}
}🤖 Prompt for AI Agents |
||
| "check:lint": "eslint . --max-warnings 10", | ||
| "check:types": "tsc --noEmit", | ||
| "check:format": "prettier --check \"**/*.{ts,tsx,md,json,css,scss}\"", | ||
|
|
@@ -20,11 +20,14 @@ | |
| "keywords": [], | ||
| "author": "", | ||
| "dependencies": { | ||
| "@dotenvx/dotenvx": "^1.49.0", | ||
| "@hocuspocus/extension-database": "^2.15.0", | ||
| "@hocuspocus/extension-logger": "^2.15.0", | ||
| "@hocuspocus/extension-redis": "^2.15.0", | ||
| "@hocuspocus/server": "^2.15.0", | ||
| "@plane/decorators": "workspace:*", | ||
| "@plane/editor": "workspace:*", | ||
| "@plane/logger": "workspace:*", | ||
| "@plane/types": "workspace:*", | ||
sriramveeraghanta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "@tiptap/core": "^2.22.3", | ||
| "@tiptap/html": "^2.22.3", | ||
|
|
@@ -42,7 +45,8 @@ | |
| "uuid": "catalog:", | ||
| "y-prosemirror": "^1.2.15", | ||
| "y-protocols": "^1.0.6", | ||
| "yjs": "^13.6.20" | ||
| "yjs": "^13.6.20", | ||
| "zod": "^3.25.76" | ||
sriramveeraghanta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| "devDependencies": { | ||
| "@plane/eslint-config": "workspace:*", | ||
|
|
@@ -54,6 +58,7 @@ | |
| "@types/node": "^20.14.9", | ||
| "@types/pino-http": "^5.8.4", | ||
| "@types/uuid": "^9.0.1", | ||
| "@types/ws": "^8.18.1", | ||
| "concurrently": "^9.0.1", | ||
| "nodemon": "^3.1.7", | ||
| "ts-node": "^10.9.2", | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import type { Hocuspocus } from "@hocuspocus/server"; | ||
| import type { Request } from "express"; | ||
| import type WebSocket from "ws"; | ||
| // plane imports | ||
| import { Controller, WebSocket as WSDecorator } from "@plane/decorators"; | ||
| import { logger } from "@plane/logger"; | ||
|
|
||
| @Controller("/collaboration") | ||
| export class CollaborationController { | ||
| [key: string]: unknown; | ||
| private readonly hocusPocusServer: Hocuspocus; | ||
|
|
||
| constructor(hocusPocusServer: Hocuspocus) { | ||
| this.hocusPocusServer = hocusPocusServer; | ||
| } | ||
|
|
||
| @WSDecorator("/") | ||
| handleConnection(ws: WebSocket, req: Request) { | ||
| try { | ||
| // Initialize the connection with Hocuspocus | ||
| this.hocusPocusServer.handleConnection(ws, req); | ||
|
|
||
| // Set up error handling for the connection | ||
| ws.on("error", (error: Error) => { | ||
| logger.error("WebSocket connection error:", error); | ||
| ws.close(1011, "Internal server error"); | ||
| }); | ||
| } catch (error) { | ||
| logger.error("WebSocket connection error:", error); | ||
| ws.close(1011, "Internal server error"); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import type { Request, Response } from "express"; | ||
| // plane imports | ||
| import { Controller, Post } from "@plane/decorators"; | ||
| import { logger } from "@plane/logger"; | ||
| // types | ||
| import type { TConvertDocumentRequestBody } from "@/types"; | ||
| // utils | ||
| import { convertHTMLDocumentToAllFormats } from "@/utils"; | ||
|
|
||
| @Controller("/convert-document") | ||
| export class ConvertDocumentController { | ||
| @Post("/") | ||
| handleConvertDocument(req: Request, res: Response) { | ||
| const { description_html, variant } = req.body as TConvertDocumentRequestBody; | ||
| try { | ||
| if (typeof description_html !== "string" || variant === undefined) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Endpoint Validation Issues Cause Unexpected BehaviorThe |
||
| res.status(400).json({ | ||
| message: "Missing required fields", | ||
| }); | ||
| return; | ||
| } | ||
| const { description, description_binary } = convertHTMLDocumentToAllFormats({ | ||
| document_html: description_html, | ||
| variant, | ||
| }); | ||
| res.status(200).json({ | ||
| description, | ||
| description_binary, | ||
| }); | ||
| } catch (error) { | ||
| logger.error("Error in /convert-document endpoint:", error); | ||
| res.status(500).json({ | ||
| message: `Internal server error.`, | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import type { Request, Response } from "express"; | ||
| import { Controller, Get } from "@plane/decorators"; | ||
| import { env } from "@/env"; | ||
|
|
||
| @Controller("/health") | ||
| export class HealthController { | ||
| @Get("/") | ||
| async healthCheck(_req: Request, res: Response) { | ||
| res.status(200).json({ | ||
| status: "OK", | ||
| timestamp: new Date().toISOString(), | ||
| version: env.APP_VERSION, | ||
| }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { CollaborationController } from "./collaboration.controller"; | ||
| import { ConvertDocumentController } from "./convert-document.controller"; | ||
| import { HealthController } from "./health.controller"; | ||
|
|
||
| export const CONTROLLERS = [CollaborationController, ConvertDocumentController, HealthController]; |
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.