chore: update project documentation, audit reports, and initialize IDE configuration files
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 29s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 2m42s
Deploy / Build Web Image (push) Failing after 27s
Deploy / Build AI Services Image (push) Failing after 29s
E2E Tests / Playwright E2E (push) Failing after 43s
Deploy / Build API Image (push) Failing after 1m31s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 6s
Security Scanning / Trivy Scan — API Image (push) Failing after 5m35s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 3m45s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Security Scanning / Trivy Scan — Web Image (push) Failing after 13m51s
Security Scanning / Trivy Filesystem Scan (push) Failing after 14m46s
Security Scanning / Security Gate (push) Has been cancelled
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 29s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 2m42s
Deploy / Build Web Image (push) Failing after 27s
Deploy / Build AI Services Image (push) Failing after 29s
E2E Tests / Playwright E2E (push) Failing after 43s
Deploy / Build API Image (push) Failing after 1m31s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 6s
Security Scanning / Trivy Scan — API Image (push) Failing after 5m35s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 3m45s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Security Scanning / Trivy Scan — Web Image (push) Failing after 13m51s
Security Scanning / Trivy Filesystem Scan (push) Failing after 14m46s
Security Scanning / Security Gate (push) Has been cancelled
This commit is contained in:
@@ -1,80 +1,80 @@
|
||||
# MCP Module - Quick Reference & Testing Guide
|
||||
# Module MCP - Tài Liệu Tham Khảo Nhanh & Hướng Dẫn Kiểm Thử
|
||||
|
||||
## 📋 Module at a Glance
|
||||
## 📋 Tổng Quan Module
|
||||
|
||||
| Aspect | Details |
|
||||
| Khía Cạnh | Chi Tiết |
|
||||
|--------|---------|
|
||||
| **Location** | `apps/api/src/modules/mcp/` |
|
||||
| **Total Files** | 4 source files |
|
||||
| **Test Files** | 1 test file (174 lines) |
|
||||
| **Architecture** | Presentation layer only |
|
||||
| **Testing Framework** | Vitest |
|
||||
| **Test Coverage** | Controller well tested ✅ |
|
||||
| **Vị Trí** | `apps/api/src/modules/mcp/` |
|
||||
| **Tổng Số Tệp** | 4 tệp nguồn |
|
||||
| **Tệp Kiểm Thử** | 1 tệp kiểm thử (174 dòng) |
|
||||
| **Kiến Trúc** | Chỉ có tầng Presentation |
|
||||
| **Framework Kiểm Thử** | Vitest |
|
||||
| **Độ Phủ Kiểm Thử** | Controller được kiểm thử đầy đủ ✅ |
|
||||
|
||||
## 📁 Complete File Listing
|
||||
## 📁 Danh Sách Tệp Đầy Đủ
|
||||
|
||||
```
|
||||
MCP Module Files:
|
||||
✅ index.ts (1 line)
|
||||
✅ mcp.module.ts (22 lines)
|
||||
✅ presentation/mcp-transport.controller.ts (102 lines)
|
||||
✅ presentation/__tests__/mcp-transport.controller.spec.ts (174 lines)
|
||||
Các Tệp Module MCP:
|
||||
✅ index.ts (1 dòng)
|
||||
✅ mcp.module.ts (22 dòng)
|
||||
✅ presentation/mcp-transport.controller.ts (102 dòng)
|
||||
✅ presentation/__tests__/mcp-transport.controller.spec.ts (174 dòng)
|
||||
```
|
||||
|
||||
## 🏗️ Architecture
|
||||
## 🏗️ Kiến Trúc
|
||||
|
||||
### Current (Simplified - Presentation Only)
|
||||
### Hiện Tại (Đơn Giản Hóa - Chỉ Có Tầng Presentation)
|
||||
```
|
||||
Presentation Layer ✅
|
||||
Tầng Presentation ✅
|
||||
├── McpTransportController
|
||||
│ ├── GET /mcp/servers
|
||||
│ ├── GET /mcp/:serverName/sse
|
||||
│ └── POST /mcp/:serverName/messages
|
||||
└── Tests (174 lines)
|
||||
└── Kiểm Thử (174 dòng)
|
||||
|
||||
McpIntegrationModule (22 lines)
|
||||
├── Module config
|
||||
├── Service setup
|
||||
└── Module lifecycle
|
||||
McpIntegrationModule (22 dòng)
|
||||
├── Cấu hình module
|
||||
├── Thiết lập service
|
||||
└── Vòng đời module
|
||||
```
|
||||
|
||||
### Missing Layers (Not Implemented)
|
||||
### Các Tầng Còn Thiếu (Chưa Được Triển Khai)
|
||||
```
|
||||
❌ Domain Layer (no entities, events, business logic)
|
||||
❌ Application Layer (no handlers, commands, queries)
|
||||
❌ Infrastructure Layer (no repositories, adapters)
|
||||
❌ Tầng Domain (không có entity, event, business logic)
|
||||
❌ Tầng Application (không có handler, command, query)
|
||||
❌ Tầng Infrastructure (không có repository, adapter)
|
||||
```
|
||||
|
||||
## 🧪 Testing Overview
|
||||
## 🧪 Tổng Quan Kiểm Thử
|
||||
|
||||
### Test File: mcp-transport.controller.spec.ts (174 lines)
|
||||
- **Total Tests**: 11
|
||||
- **Test Suites**: 4 describe blocks
|
||||
- **Coverage**: 100% of controller endpoints
|
||||
### Tệp Kiểm Thử: mcp-transport.controller.spec.ts (174 dòng)
|
||||
- **Tổng Số Kiểm Thử**: 11
|
||||
- **Bộ Kiểm Thử**: 4 khối describe
|
||||
- **Độ Phủ**: 100% các endpoint của controller
|
||||
|
||||
### Test Breakdown
|
||||
### Phân Tích Kiểm Thử
|
||||
```
|
||||
1. Security Decorators (4 tests)
|
||||
├── JwtAuthGuard applied
|
||||
├── listServers throttle (30 req/60s)
|
||||
├── handleSse throttle (5 req/60s) ⚡ stricter
|
||||
└── handleMessage throttle (30 req/60s)
|
||||
1. Decorator Bảo Mật (4 kiểm thử)
|
||||
├── JwtAuthGuard được áp dụng
|
||||
├── Giới hạn tốc độ listServers (30 yêu cầu/60 giây)
|
||||
├── Giới hạn tốc độ handleSse (5 yêu cầu/60 giây) ⚡ chặt chẽ hơn
|
||||
└── Giới hạn tốc độ handleMessage (30 yêu cầu/60 giây)
|
||||
|
||||
2. listServers (2 tests)
|
||||
├── Returns server list
|
||||
└── Handles empty list
|
||||
2. listServers (2 kiểm thử)
|
||||
├── Trả về danh sách server
|
||||
└── Xử lý danh sách rỗng
|
||||
|
||||
3. handleSse (3 tests)
|
||||
├── Throws NOT_FOUND for missing server
|
||||
├── Creates transport & connects
|
||||
└── Cleans up on connection close
|
||||
3. handleSse (3 kiểm thử)
|
||||
├── Ném NOT_FOUND khi server không tồn tại
|
||||
├── Tạo transport & kết nối
|
||||
└── Dọn dẹp khi đóng kết nối
|
||||
|
||||
4. handleMessage (2 tests)
|
||||
├── Throws BAD_REQUEST for missing sessionId
|
||||
└── Throws NOT_FOUND for expired session
|
||||
4. handleMessage (2 kiểm thử)
|
||||
├── Ném BAD_REQUEST khi thiếu sessionId
|
||||
└── Ném NOT_FOUND khi session đã hết hạn
|
||||
```
|
||||
|
||||
## 🎯 Key Classes
|
||||
## 🎯 Các Lớp Chính
|
||||
|
||||
### McpIntegrationModule
|
||||
```typescript
|
||||
@@ -86,7 +86,7 @@ class McpIntegrationModule implements OnModuleInit {
|
||||
) {}
|
||||
|
||||
async onModuleInit(): Promise<void> {
|
||||
// Set typesense client, re-initialize servers, log results
|
||||
// Thiết lập typesense client, khởi tạo lại server, ghi log kết quả
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -104,9 +104,9 @@ class McpTransportController {
|
||||
}
|
||||
```
|
||||
|
||||
## 🔧 Testing Patterns
|
||||
## 🔧 Các Mẫu Kiểm Thử
|
||||
|
||||
### Module Mocking
|
||||
### Mock Module
|
||||
```typescript
|
||||
vi.mock('@goodgo/mcp-servers', () => ({
|
||||
SSEServerTransport: class MockSSE {
|
||||
@@ -116,7 +116,7 @@ vi.mock('@goodgo/mcp-servers', () => ({
|
||||
}));
|
||||
```
|
||||
|
||||
### Service Mocking
|
||||
### Mock Service
|
||||
```typescript
|
||||
mockRegistry = {
|
||||
getServerNames: vi.fn(),
|
||||
@@ -124,60 +124,59 @@ mockRegistry = {
|
||||
};
|
||||
```
|
||||
|
||||
### Decorator Verification
|
||||
### Xác Minh Decorator
|
||||
```typescript
|
||||
const guards = Reflect.getMetadata('__guards__', McpTransportController);
|
||||
const throttleLimit = Reflect.getMetadata('THROTTLER:LIMITdefault', method);
|
||||
```
|
||||
|
||||
## 📚 Testing Examples from Other Modules
|
||||
## 📚 Ví Dụ Kiểm Thử Từ Các Module Khác
|
||||
|
||||
### Auth Module Pattern (Simple)
|
||||
- Minimal dependencies
|
||||
- Direct handler instantiation
|
||||
- Focus on behavior verification
|
||||
### Mẫu Module Auth (Đơn Giản)
|
||||
- Ít phụ thuộc
|
||||
- Khởi tạo handler trực tiếp
|
||||
- Tập trung vào xác minh hành vi
|
||||
|
||||
### Payments Module Pattern (Complex)
|
||||
- Multiple dependency mocks
|
||||
- Business rule testing
|
||||
- Event bus verification
|
||||
### Mẫu Module Payments (Phức Tạp)
|
||||
- Nhiều mock phụ thuộc
|
||||
- Kiểm thử quy tắc nghiệp vụ
|
||||
- Xác minh event bus
|
||||
|
||||
### Domain Entity Pattern
|
||||
- Explicit vitest imports
|
||||
- State transition testing
|
||||
- Domain event verification
|
||||
- Error handling with Result types
|
||||
### Mẫu Domain Entity
|
||||
- Import vitest tường minh
|
||||
- Kiểm thử chuyển đổi trạng thái
|
||||
- Xác minh domain event
|
||||
- Xử lý lỗi với kiểu Result
|
||||
|
||||
### Infrastructure Pattern
|
||||
- External service simulation
|
||||
- Security testing (crypto)
|
||||
- Complex test data builders
|
||||
### Mẫu Infrastructure
|
||||
- Mô phỏng dịch vụ bên ngoài
|
||||
- Kiểm thử bảo mật (crypto)
|
||||
- Các builder dữ liệu kiểm thử phức tạp
|
||||
|
||||
## 🚀 Running Tests
|
||||
## 🚀 Chạy Kiểm Thử
|
||||
|
||||
```bash
|
||||
# Run all MCP tests
|
||||
# Chạy tất cả kiểm thử MCP
|
||||
pnpm test -- src/modules/mcp
|
||||
|
||||
# Run with watch
|
||||
# Chạy ở chế độ watch
|
||||
pnpm test -- --watch src/modules/mcp
|
||||
|
||||
# Run with coverage
|
||||
# Chạy với coverage
|
||||
pnpm test -- --coverage src/modules/mcp
|
||||
|
||||
# Run specific test
|
||||
# Chạy kiểm thử cụ thể
|
||||
pnpm test -- src/modules/mcp/presentation/__tests__/mcp-transport.controller.spec.ts
|
||||
```
|
||||
|
||||
## 💡 Recommendations
|
||||
## 💡 Khuyến Nghị
|
||||
|
||||
### High Priority
|
||||
- ✅ Controller is well tested - maintain this
|
||||
- 📝 Add tests for McpIntegrationModule.onModuleInit()
|
||||
- 📝 Test module dependency injection
|
||||
|
||||
### Lower Priority
|
||||
- 🏗️ If domain logic added, follow payments patterns
|
||||
- 🏗️ If handlers added, use CQRS patterns
|
||||
- 🏗️ Add integration tests for SSE lifecycle
|
||||
### Ưu Tiên Cao
|
||||
- ✅ Controller được kiểm thử tốt - duy trì điều này
|
||||
- 📝 Thêm kiểm thử cho McpIntegrationModule.onModuleInit()
|
||||
- 📝 Kiểm thử dependency injection của module
|
||||
|
||||
### Ưu Tiên Thấp Hơn
|
||||
- 🏗️ Nếu thêm domain logic, theo mẫu payments
|
||||
- 🏗️ Nếu thêm handler, sử dụng mẫu CQRS
|
||||
- 🏗️ Thêm kiểm thử tích hợp cho vòng đời SSE
|
||||
|
||||
Reference in New Issue
Block a user