Skip to content

Feature/API-59/add-websocket-order-detail#91

Merged
andres15alvarez merged 7 commits into
devfrom
feature/add-websocket-order-detail
May 3, 2025
Merged

Feature/API-59/add-websocket-order-detail#91
andres15alvarez merged 7 commits into
devfrom
feature/add-websocket-order-detail

Conversation

@andres15alvarez
Copy link
Copy Markdown
Member

This pull request introduces WebSocket support to the application, enabling real-time communication for order updates and user management. Key changes include adding WebSocket-related dependencies, implementing WebSocket guards and services for authentication and role-based access control, and creating a WebSocket gateway for managing order updates.

WebSocket Integration

  • Added new dependencies: @nestjs/platform-socket.io and @nestjs/websockets to support WebSocket functionality (package.json, package.jsonR34-R37).
  • Introduced OrderGateway to handle WebSocket connections, disconnections, and order update messages. It utilizes guards for authentication and role-based access control (src/order/order.gateway.ts, src/order/order.gateway.tsR1-R67).
  • Added DTO UpdateOrderStatusWsDTO for validating WebSocket message payloads related to order updates (src/order/dto/order.ts, src/order/dto/order.tsR183-R196).

WebSocket Authentication and Role-Based Access Control

  • Created AuthGuardWs to verify JWT tokens in WebSocket connections and attach authenticated user data to the socket (src/auth/auth.guard.ts, src/auth/auth.guard.tsR55-R86).
  • Added RolesGuardWs to enforce role-based access control for WebSocket events (src/auth/roles.guard.ts, src/auth/roles.guard.tsR51-R82).

User Management for WebSocket Connections

Order Management Enhancements

  • Updated OrderService to include a method getUserByOrderId for retrieving the user associated with an order, enabling targeted WebSocket notifications (src/order/order.service.ts, src/order/order.service.tsR485-R495).
  • Modified the order status update logic to ensure proper state transitions (src/order/order.service.ts, src/order/order.service.tsL218-R221).

@andres15alvarez andres15alvarez added the feature New feature or request label May 3, 2025
@andres15alvarez andres15alvarez self-assigned this May 3, 2025
@andres15alvarez andres15alvarez marked this pull request as ready for review May 3, 2025 20:11
@andres15alvarez andres15alvarez merged commit 583fecc into dev May 3, 2025
2 checks passed
@andres15alvarez andres15alvarez deleted the feature/add-websocket-order-detail branch May 3, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant