MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / registerConfigRoutes

Function registerConfigRoutes

packages/server/src/routes/config.ts:30–71  ·  view source on GitHub ↗
(app: ConfigRouteHost, ix: IInstantiationService)

Source from the content-addressed store, hash-verified

28}
29
30export function registerConfigRoutes(app: ConfigRouteHost, ix: IInstantiationService): void {
31 const getRoute = defineRoute(
32 {
33 method: 'GET',
34 path: '/config',
35 success: { data: configResponseSchema },
36 description: 'Get the global Kimi configuration (secrets redacted)',
37 tags: ['config'],
38 },
39 async (req, reply) => {
40 const config = await ix.invokeFunction((a) => a.get(IConfigService).get());
41 reply.send(okEnvelope(config, req.id));
42 },
43 );
44 app.get(getRoute.path, getRoute.options, getRoute.handler as Parameters<ConfigRouteHost['get']>[2]);
45
46 const setRoute = defineRoute(
47 {
48 method: 'POST',
49 path: '/config',
50 body: patchConfigRequestSchema,
51 success: { data: configResponseSchema },
52 errors: {
53 [ErrorCode.VALIDATION_FAILED]: {},
54 },
55 description: 'Update the global Kimi configuration (merge semantics)',
56 tags: ['config'],
57 },
58 async (req, reply) => {
59 try {
60 const config = await ix.invokeFunction((a) =>
61 a.get(IConfigService).set(req.body),
62 );
63 reply.send(okEnvelope(config, req.id));
64 } catch (err) {
65 const message = err instanceof Error ? err.message : String(err);
66 reply.send(errEnvelope(ErrorCode.VALIDATION_FAILED, message, req.id));
67 }
68 },
69 );
70 app.post(setRoute.path, setRoute.options, setRoute.handler as Parameters<ConfigRouteHost['post']>[2]);
71}

Callers 1

registerApiV1RoutesFunction · 0.90

Calls 8

defineRouteFunction · 0.90
okEnvelopeFunction · 0.90
errEnvelopeFunction · 0.90
invokeFunctionMethod · 0.65
getMethod · 0.65
sendMethod · 0.65
setMethod · 0.65
postMethod · 0.65

Tested by

no test coverage detected