Restructure Project Architecture with Modular Routes and Configuration
- Refactored main application entry point to use centralized configuration - Created modular route structure with separate files for different API endpoints - Introduced app.config.ts for centralized environment variable management - Moved tools and route logic into dedicated files - Simplified index.ts and improved overall project organization - Added comprehensive type definitions for tools and API interactions
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
import { z } from 'zod';
|
||||
import { get_hass } from '../hass/index.js';
|
||||
import { Tool } from '../types/index.js';
|
||||
import { listDevicesTool } from './list-devices.tool.js';
|
||||
import { controlTool } from './control.tool.js';
|
||||
import { historyTool } from './history.tool.js';
|
||||
import { sceneTool } from './scene.tool.js';
|
||||
import { notifyTool } from './notify.tool.js';
|
||||
import { automationTool } from './automation.tool.js';
|
||||
import { addonTool } from './addon.tool.js';
|
||||
import { packageTool } from './package.tool.js';
|
||||
import { automationConfigTool } from './automation-config.tool.js';
|
||||
import { subscribeEventsTool } from './subscribe-events.tool.js';
|
||||
import { getSSEStatsTool } from './sse-stats.tool.js';
|
||||
|
||||
// Tool category types
|
||||
export enum ToolCategory {
|
||||
@@ -188,4 +200,44 @@ export class LightControlTool implements EnhancedTool {
|
||||
// Implementation here
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Array to track all tools
|
||||
const tools: Tool[] = [
|
||||
listDevicesTool,
|
||||
controlTool,
|
||||
historyTool,
|
||||
sceneTool,
|
||||
notifyTool,
|
||||
automationTool,
|
||||
addonTool,
|
||||
packageTool,
|
||||
automationConfigTool,
|
||||
subscribeEventsTool,
|
||||
getSSEStatsTool
|
||||
];
|
||||
|
||||
// Function to get a tool by name
|
||||
export function getToolByName(name: string): Tool | undefined {
|
||||
return tools.find(tool => tool.name === name);
|
||||
}
|
||||
|
||||
// Function to get all tools
|
||||
export function getAllTools(): Tool[] {
|
||||
return [...tools];
|
||||
}
|
||||
|
||||
// Export all tools individually
|
||||
export {
|
||||
listDevicesTool,
|
||||
controlTool,
|
||||
historyTool,
|
||||
sceneTool,
|
||||
notifyTool,
|
||||
automationTool,
|
||||
addonTool,
|
||||
packageTool,
|
||||
automationConfigTool,
|
||||
subscribeEventsTool,
|
||||
getSSEStatsTool
|
||||
};
|
||||
Reference in New Issue
Block a user