Refactor: delete dead code, extract utils, rename files for clarity
- Delete scheduler-mcp.ts (285 lines of dead code, unused) - Extract loadJson/saveJson to utils.ts (generic utilities) - Rename auth.ts → whatsapp-auth.ts (more specific) - Rename scheduler.ts → task-scheduler.ts (more specific) - Update all references in docs and imports Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
18
src/utils.ts
Normal file
18
src/utils.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export function loadJson<T>(filePath: string, defaultValue: T): T {
|
||||
try {
|
||||
if (fs.existsSync(filePath)) {
|
||||
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
||||
}
|
||||
} catch {
|
||||
// Return default on error
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
export function saveJson(filePath: string, data: unknown): void {
|
||||
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
||||
fs.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
||||
}
|
||||
Reference in New Issue
Block a user