From 3ef82991fb50f355ed295195acd9e4d57e9a9db4 Mon Sep 17 00:00:00 2001 From: "jinhui.li" Date: Thu, 3 Jul 2025 17:19:26 +0800 Subject: [PATCH] support json config --- src/index.ts | 16 ++++++++++++---- src/server.ts | 4 +--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index d5e4361..569df97 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,6 +10,7 @@ import { isServiceRunning, savePid, } from "./utils/processCheck"; +import { CONFIG_FILE } from "./constants"; async function initializeClaudeConfig() { const homeDir = process.env.HOME; @@ -69,10 +70,17 @@ async function run(options: RunOptions = {}) { ? parseInt(process.env.SERVICE_PORT) : port; const server = createServer({ - ...config, - providers: config.Providers || config.providers, - PORT: servicePort, - LOG_FILE: join(homedir(), ".claude-code-router", "claude-code-router.log"), + jsonPath: CONFIG_FILE, + initialConfig: { + // ...config, + providers: config.Providers || config.providers, + PORT: servicePort, + LOG_FILE: join( + homedir(), + ".claude-code-router", + "claude-code-router.log" + ), + }, }); server.addHook("preHandler", async (req, reply) => router(req, reply, config) diff --git a/src/server.ts b/src/server.ts index 9d90724..c639404 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,8 +1,6 @@ import Server from "@musistudio/llms"; export const createServer = (config: any): Server => { - const server = new Server({ - initialConfig: config, - }); + const server = new Server(config); return server; };