Skip to content

Conversation

@hikuohiku
Copy link
Collaborator

@hikuohiku hikuohiku commented Aug 18, 2025

バックエンド側にWebsocket関連のインターフェイスになるサービスを生やしました。

やったこと

  • WebSocketDonChannelWebSocketOrderChannelクラスの実装
    AsyncAPIのチャンネルの概念に合わせて、donChannelとorderChannelでそれぞれ別のサービスとして実装しました。
    API specでdonと記載があるOperationはdonChannelが、orderと記載のあるOperationはorderChannelが扱う形です。

    インターフェイスもAsyncAPI仕様に合わせていて、サーバー側からメッセージ送信するアクションをそのまま公開メソッドにしている感じです。

  • テストの実装

  • loggerの機能追加

    • developmentモードの時にターミナルにオブジェクトをprintするように
    • testモードの時にprintするログレベルをerrorに

一応手元のWebsocketクライアントでサーバー起動して叩ける確認はしてます

やってないこと

  • donStateやorderStateを取得する処理の実装
    • インターフェイス層の責務ではないので実装していません
    • が、今の実装自体レイヤードアーキテクチャではないので他の実装次第ではここにその処理を書く必要が出てくると思っています

@hikuohiku hikuohiku force-pushed the feature/websocket-backend branch 5 times, most recently from 9a324b1 to f1c19dc Compare August 20, 2025 11:20
@hikuohiku hikuohiku force-pushed the feature/websocket-backend branch from f1c19dc to 20767d6 Compare August 28, 2025 11:21
@hikuohiku hikuohiku changed the title [WIP]Websocketバックエンド実装 Websocketバックエンド実装 Aug 28, 2025
@hikuohiku hikuohiku force-pushed the feature/websocket-backend branch 3 times, most recently from 4a9b424 to dc6de98 Compare August 28, 2025 11:59
@hikuohiku hikuohiku requested a review from Copilot August 28, 2025 12:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements WebSocket backend infrastructure for real-time communication. It introduces two separate WebSocket channels (WebSocketDonChannel and WebSocketOrderChannel) aligned with AsyncAPI specifications, following a channel-based architecture where don-related operations are handled by the don channel and order-related operations by the order channel.

  • Implements WebSocket communication channels for don and order state notifications
  • Adds comprehensive test coverage for WebSocket functionality
  • Enhances logger configuration with environment-specific settings

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/backend/src/websocket/donChannel.ts Implements WebSocket channel for don state notifications with subscription management
packages/backend/src/websocket/orderChannel.ts Implements WebSocket channel for order state notifications with include option support
packages/backend/src/websocket/messages.ts Defines TypeScript types for WebSocket message schemas per AsyncAPI spec
packages/backend/src/utils/logger.ts Enhances logger with metadata support and test-specific log level configuration
packages/backend/src/utils/errorMessage.ts Adds utility function for formatting typia validation errors
packages/backend/src/index.ts Integrates WebSocket server with periodic notification testing
packages/backend/vitest.config.ts Configures test environment with path aliases and NODE_ENV
packages/backend/tsconfig.json Adds typia transformer plugin and enables strict null checks
packages/backend/package.json Adds WebSocket and typia dependencies with ts-patch setup script
docker-compose.local.yml Exposes WebSocket port for development
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

import { Don, DonStateMessage, RequestNotificationMessage } from './messages';
import { typiaValidationErrorMessage } from '@/utils/errorMessage';

interface DonChannel {
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DonChannel interface should be exported to allow other modules to import and use it for dependency injection or testing purposes.

Suggested change
interface DonChannel {
export interface DonChannel {

Copilot uses AI. Check for mistakes.
@hikuohiku hikuohiku force-pushed the feature/websocket-backend branch from dc6de98 to 30f33b2 Compare August 28, 2025 12:33
@hikuohiku hikuohiku marked this pull request as ready for review August 28, 2025 12:52
@hikuohiku hikuohiku requested review from Atotti and taniiicom August 28, 2025 12:52
@hikuohiku hikuohiku force-pushed the feature/websocket-backend branch from b7848c7 to a126195 Compare September 6, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants