- 
                Notifications
    
You must be signed in to change notification settings  - Fork 65
 
Feat: Slave Mode #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Slave Mode #13
Conversation
…d detailed results
…with hashed passwords from backup
- Updated SlaveNode interface to include sync configuration and metrics. - Implemented database migration for slave nodes and sync logs. - Created API endpoints for registering, updating, deleting, and syncing slave nodes. - Added middleware for validating slave API keys. - Developed service layer for handling slave node operations. - Implemented query options for fetching slave nodes and their statuses. - Enhanced mock data for slave nodes to include new fields.
- Introduced SystemConfig interface in types for managing node configurations. - Created migration for system_configs table with necessary fields and enum for node modes. - Implemented system configuration controller with endpoints to get, update, connect, disconnect, and test connection to master node. - Added routes for system configuration management. - Developed service methods for API interactions related to system configuration. - Implemented query options for fetching system configuration with automatic refetching.
There was a problem hiding this 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 introduces a comprehensive "Slave Mode" feature that enables master-slave replication for nginx configuration management. The feature includes both manual and automated backup functionality, along with a robust synchronization system for distributed nginx nodes.
Key changes:
- Implements master-slave node architecture with real-time synchronization
 - Adds comprehensive backup and restore functionality with file-based storage
 - Creates automatic status monitoring for slave node health tracking
 
Reviewed Changes
Copilot reviewed 25 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description | 
|---|---|
| apps/web/src/types/index.ts | Extends SlaveNode interface with metrics and adds SystemConfig interface | 
| apps/web/src/services/system-config.service.ts | New service for managing system configuration and master-slave connections | 
| apps/web/src/services/slave.service.ts | New service for slave node management with CRUD operations | 
| apps/web/src/services/backup.service.ts | New service for backup operations and configuration import/export | 
| apps/web/src/queries/*.ts | New query options for system config and slave nodes using React Query | 
| apps/web/src/mocks/data.ts | Updates mock data with new slave node properties | 
| apps/web/src/components/pages/SlaveNodes.tsx | Complete rewrite to implement master-slave mode switching UI | 
| apps/web/src/components/pages/Backup.tsx | Complete rewrite with real API integration and comprehensive restore functionality | 
| apps/api/src/utils/slave-status-checker.ts | New utility for monitoring slave node health status | 
| apps/api/src/routes/*.ts | New route definitions for system config, slave management, and backup operations | 
| apps/api/src/middleware/slaveAuth.ts | New authentication middleware for slave node API key validation | 
| apps/api/src/index.ts | Integration of slave node status monitoring service | 
| apps/api/src/controllers/*.ts | New controllers for system config, slave management, backup, and node synchronization | 
| apps/api/prisma/schema.prisma | Database schema extensions for backup, slave nodes, and system configuration | 
| apps/api/prisma/migrations/*.sql | Database migrations for new feature tables and enums | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| * Get system configuration (node mode, }); | ||
| logger.info('Disconnected from master node', { | ||
| userId: req.user?.userId | ||
| });er/slave settings) | 
    
      
    
      Copilot
AI
    
    
    
      Oct 6, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There appears to be corrupted comment and code mixing. The comment is incomplete and contains what looks like misplaced code from another function. This should be a clean JSDoc comment describing the function purpose.
| * Get system configuration (node mode, }); | |
| logger.info('Disconnected from master node', { | |
| userId: req.user?.userId | |
| });er/slave settings) | |
| * Get system configuration (node mode, master/slave settings) | 
| export const mockPerformanceMetrics: PerformanceMetric[] = Array.from({ length: 20 }, (_, i) => ({ | ||
| id: `perf${i + 1}`, | ||
| domain: ['api.example.com', 'app.production.com', 'cdn.assets.com'][i % 3], | ||
| domain: ['api.example.com', 'app.production.com', 'cdn.assets.com'][i % 3] || 'api.example.com', | 
    
      
    
      Copilot
AI
    
    
    
      Oct 6, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback || 'api.example.com' is unnecessary since the modulo operation i % 3 will always return 0, 1, or 2, which are valid indices for the 3-element array. This will never be undefined.
| domain: ['api.example.com', 'app.production.com', 'cdn.assets.com'][i % 3] || 'api.example.com', | |
| domain: ['api.example.com', 'app.production.com', 'cdn.assets.com'][i % 3], | 
| import { useState } from "react"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; | 
    
      
    
      Copilot
AI
    
    
    
      Oct 6, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The import statement is missing useEffect which might be needed for component lifecycle management, though it's not currently used in the visible code.
…nd ACLs for clarity; remove unused URL validation utility
          
 | 
    
| try { | ||
| logger.info('Testing connection to master...', { masterHost, masterPort }); | ||
| 
               | 
          ||
| const response = await axios.get( | 
Check warning
Code scanning / SonarCloud
Server-side requests should not be vulnerable to forging attacks Medium
* Feat: Update Features Backup & Restore (#12) * feat: Update Features Backup & Restore * Feat: Slave Mode (#13) * feat: Update Features Backup & Restore * Feat: Features update (#14) * feat: Update software * Features update version and update noti Change Password (#15) * feat: Update Features Backup & Restore * Fix frontend error (#16) * Refactor services to use centralized API module and token storage * Feat: Enhance Slave Mode UI with mode switch button and update node mode mutation * feat: Improve SSLDialog layout with enhanced text wrapping for certificate fields * refactor: replace js-cookie with localStorage for token management (#17) * feat: add syncInterval and lastSyncHash columns to system_configs table (#18) * feat: Update project goal description and remove security recommendation * feat: Update project goal description and remove security recommendation * About readme (#21) * feat: Update project goal description and remove security recommendation * Refactor be (#22) * Refactor code structure for improved readability and maintainability * style: limit max height of certificate, private key, and chain input fields (#23) --------- Co-authored-by: SangND <dacsang97@gmail.com>




No description provided.