Files
goodgo-platform/apps/api/src/modules/messaging/messaging.module.ts
Ho Ngoc Hai 3b5da2dcf9 feat(messaging): add in-app messaging module with Conversation + Message models
Implements buyer-agent in-app messaging (Task 8.4):
- Prisma models: Conversation, ConversationParticipant, Message
- Full DDD module: domain entities, repository interfaces, CQRS commands/queries
- REST API: POST/GET conversations, POST/GET messages, PATCH read, DELETE messages
- WebSocket gateway (/messaging namespace): real-time message delivery, typing indicators, room-based routing
- 46 unit tests covering handlers, repositories, controller, and gateway

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-16 05:36:04 +07:00

45 lines
1.8 KiB
TypeScript

import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { AuthModule } from '@modules/auth';
import { CreateConversationHandler } from './application/commands/create-conversation/create-conversation.handler';
import { MarkConversationReadHandler } from './application/commands/mark-read/mark-read.handler';
import { SendMessageHandler } from './application/commands/send-message/send-message.handler';
import { GetConversationsHandler } from './application/queries/get-conversations/get-conversations.handler';
import { GetMessagesHandler } from './application/queries/get-messages/get-messages.handler';
import { CONVERSATION_REPOSITORY } from './domain/repositories/conversation.repository';
import { MESSAGE_REPOSITORY } from './domain/repositories/message.repository';
import { PrismaConversationRepository } from './infrastructure/repositories/prisma-conversation.repository';
import { PrismaMessageRepository } from './infrastructure/repositories/prisma-message.repository';
import { MessagingController } from './presentation/controllers/messaging.controller';
import { MessagingGateway } from './presentation/gateways/messaging.gateway';
const CommandHandlers = [
CreateConversationHandler,
SendMessageHandler,
MarkConversationReadHandler,
];
const QueryHandlers = [
GetConversationsHandler,
GetMessagesHandler,
];
@Module({
imports: [CqrsModule, AuthModule],
controllers: [MessagingController],
providers: [
// Repositories
{ provide: CONVERSATION_REPOSITORY, useClass: PrismaConversationRepository },
{ provide: MESSAGE_REPOSITORY, useClass: PrismaMessageRepository },
// WebSocket Gateway
MessagingGateway,
// CQRS
...CommandHandlers,
...QueryHandlers,
],
exports: [MessagingGateway],
})
export class MessagingModule {}