support json config

This commit is contained in:
jinhui.li
2025-07-03 17:19:26 +08:00
parent f9ba3805a6
commit 3ef82991fb
2 changed files with 13 additions and 7 deletions

View File

@@ -10,6 +10,7 @@ import {
isServiceRunning, isServiceRunning,
savePid, savePid,
} from "./utils/processCheck"; } from "./utils/processCheck";
import { CONFIG_FILE } from "./constants";
async function initializeClaudeConfig() { async function initializeClaudeConfig() {
const homeDir = process.env.HOME; const homeDir = process.env.HOME;
@@ -69,10 +70,17 @@ async function run(options: RunOptions = {}) {
? parseInt(process.env.SERVICE_PORT) ? parseInt(process.env.SERVICE_PORT)
: port; : port;
const server = createServer({ const server = createServer({
...config, jsonPath: CONFIG_FILE,
providers: config.Providers || config.providers, initialConfig: {
PORT: servicePort, // ...config,
LOG_FILE: join(homedir(), ".claude-code-router", "claude-code-router.log"), providers: config.Providers || config.providers,
PORT: servicePort,
LOG_FILE: join(
homedir(),
".claude-code-router",
"claude-code-router.log"
),
},
}); });
server.addHook("preHandler", async (req, reply) => server.addHook("preHandler", async (req, reply) =>
router(req, reply, config) router(req, reply, config)

View File

@@ -1,8 +1,6 @@
import Server from "@musistudio/llms"; import Server from "@musistudio/llms";
export const createServer = (config: any): Server => { export const createServer = (config: any): Server => {
const server = new Server({ const server = new Server(config);
initialConfig: config,
});
return server; return server;
}; };