mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
🧬 refactor: Wire Database Methods into MCP Package via Registry Pattern (#10715)
* Refactor: MCPServersRegistry Singleton Pattern with Dependency Injection for DB methods consumption * refactor: error handling in MCP initialization and improve logging for MCPServersRegistry instance creation. - Added checks for mongoose instance in ServerConfigsDB constructor and refined error messages for clarity. - Reorder and use type imports --------- Co-authored-by: Atef Bellaaj <slalom.bellaaj@external.daimlertruck.com> Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
parent
2263931a32
commit
25c9c89d7a
24 changed files with 328 additions and 150 deletions
|
|
@ -21,18 +21,21 @@ jest.mock('../MCPConnectionFactory', () => ({
|
|||
jest.mock('../connection');
|
||||
|
||||
// Mock the registry
|
||||
const mockRegistryInstance = {
|
||||
getServerConfig: jest.fn(),
|
||||
getAllServerConfigs: jest.fn(),
|
||||
};
|
||||
|
||||
jest.mock('../registry/MCPServersRegistry', () => ({
|
||||
mcpServersRegistry: {
|
||||
getServerConfig: jest.fn(),
|
||||
getAllServerConfigs: jest.fn(),
|
||||
MCPServersRegistry: {
|
||||
getInstance: () => mockRegistryInstance,
|
||||
},
|
||||
}));
|
||||
|
||||
const mockLogger = logger as jest.Mocked<typeof logger>;
|
||||
|
||||
// Import mocked registry
|
||||
import { mcpServersRegistry as registry } from '../registry/MCPServersRegistry';
|
||||
const mockRegistry = registry as jest.Mocked<typeof registry>;
|
||||
// Use mocked registry instance
|
||||
const mockRegistry = mockRegistryInstance as jest.Mocked<typeof mockRegistryInstance>;
|
||||
|
||||
describe('ConnectionsRepository', () => {
|
||||
let repository: ConnectionsRepository;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue