support json config
This commit is contained in:
16
src/index.ts
16
src/index.ts
@@ -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)
|
||||||
|
|||||||
@@ -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;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user