feat: enhance frontend with new UI components and Tailwind CSS integration

- Added CreateButton and DocumentCard components for document management.
- Implemented tabbed interface for owned and shared documents in Home page.
- Integrated Tailwind CSS for styling and layout improvements.
- Introduced utility functions for class name management.
- Updated package.json with new dependencies for UI components and styling.
- Created PostCSS configuration for Tailwind CSS.
- Refactored Navbar and button components for better usability and design.
- Enhanced document API to include owner_id for document sharing functionality.
This commit is contained in:
M1ngdaXie
2026-02-05 15:06:34 -08:00
parent c84cbafb2c
commit 6fac2f7997
25 changed files with 2547 additions and 121 deletions

View File

@@ -3,6 +3,7 @@ package handlers
import (
"log"
"net/http"
"time"
"github.com/M1ngdaXie/realtime-collab/internal/auth"
"github.com/M1ngdaXie/realtime-collab/internal/config"
@@ -13,6 +14,10 @@ import (
"github.com/gorilla/websocket"
)
// connectionSem limits concurrent WebSocket connection handshakes
// to prevent overwhelming the database during connection storms
var connectionSem = make(chan struct{}, 200)
type WebSocketHandler struct {
hub *hub.Hub
store store.Store
@@ -44,6 +49,15 @@ func (wsh *WebSocketHandler) getUpgrader() websocket.Upgrader {
}
func (wsh *WebSocketHandler) HandleWebSocket(c *gin.Context) {
// Acquire semaphore to limit concurrent connection handshakes
select {
case connectionSem <- struct{}{}:
defer func() { <-connectionSem }()
case <-time.After(10 * time.Second):
c.JSON(http.StatusServiceUnavailable, gin.H{"error": "server busy, retry later"})
return
}
roomID := c.Param("roomId")
if roomID == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "roomId is required"})