Feature/API-59/add-websocket-order-detail#91
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
@nestjs/platform-socket.ioand@nestjs/websocketsto support WebSocket functionality (package.json, package.jsonR34-R37).OrderGatewayto 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).UpdateOrderStatusWsDTOfor 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
AuthGuardWsto 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).RolesGuardWsto enforce role-based access control for WebSocket events (src/auth/roles.guard.ts, src/auth/roles.guard.tsR51-R82).User Management for WebSocket Connections
wsIdfield to theUserentity to track WebSocket connections (src/user/entities/user.entity.ts, src/user/entities/user.entity.tsR92-R94).setWsIdandremoveWsIdinUserServiceto manage WebSocket connection IDs (src/user/user.service.ts, src/user/user.service.tsR373-R390).ws_idcolumn in theusertable (src/user/migrations/1746249862267-add-ws-id-user-migration.ts, src/user/migrations/1746249862267-add-ws-id-user-migration.tsR1-R13).Order Management Enhancements
OrderServiceto include a methodgetUserByOrderIdfor retrieving the user associated with an order, enabling targeted WebSocket notifications (src/order/order.service.ts, src/order/order.service.tsR485-R495).src/order/order.service.ts, src/order/order.service.tsL218-R221).