mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 04:15:52 +00:00
fix(dashboard): support unified config.yaml in web server routes
Add loadConfigSafe() function that handles both unified (config.yaml) and legacy (config.json) config formats. Uses throwable errors instead of process.exit() so try/catch blocks work properly in web server routes. Updated files to use loadConfigSafe(): - overview-routes.ts: Dashboard overview API - route-helpers.ts: readConfigSafe() helper - profile-reader.ts: API profile reading - profile-writer.ts: API profile writing - variant-config-adapter.ts: CLIProxy variant config Fixes #206 (Problem 2: config.json not found when user has config.yaml)
This commit is contained in:
1 parent
2093ae2cc8
commit
0c69740694
7 files changed
+74
-15
No files matched your search
@@ -7,7 +7,7 @@
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { getCcsDir, loadConfig } from '../../utils/config-manager';
|
||||
import { getCcsDir, loadConfigSafe } from '../../utils/config-manager';
|
||||
import { loadOrCreateUnifiedConfig, isUnifiedMode } from '../../config/unified-config-loader';
|
||||
import type { ApiProfileInfo, CliproxyVariantInfo, ApiListResult } from './profile-types';
|
||||
|
||||
@@ -20,7 +20,7 @@ export function apiProfileExists(name: string): boolean {
|
||||
const config = loadOrCreateUnifiedConfig();
|
||||
return name in config.profiles;
|
||||
}
|
||||
const config = loadConfig();
|
||||
const config = loadConfigSafe();
|
||||
return name in config.profiles;
|
||||
} catch {
|
||||
return false;
|
||||
@@ -79,7 +79,7 @@ export function listApiProfiles(): ApiListResult {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const config = loadConfig();
|
||||
const config = loadConfigSafe();
|
||||
for (const [name, settingsPath] of Object.entries(config.profiles)) {
|
||||
// Skip 'default' profile - it's the user's native Claude settings
|
||||
if (name === 'default' && (settingsPath as string).includes('.claude/settings.json')) {
|
||||
@@ -116,7 +116,7 @@ export function getApiProfileNames(): string[] {
|
||||
const config = loadOrCreateUnifiedConfig();
|
||||
return Object.keys(config.profiles);
|
||||
}
|
||||
const config = loadConfig();
|
||||
const config = loadConfigSafe();
|
||||
return Object.keys(config.profiles);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user