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

Function registerGuiStoreRoutes

packages/server/src/routes/guiStore.ts:36–146  ·  view source on GitHub ↗
(
  app: GuiStoreRouteHost,
  ix: IInstantiationService,
)

Source from the content-addressed store, hash-verified

34}
35
36export function registerGuiStoreRoutes(
37 app: GuiStoreRouteHost,
38 ix: IInstantiationService,
39): void {
40 const getItemRoute = defineRoute(
41 {
42 method: 'GET',
43 path: '/gui/store/getItem',
44 querystring: guiStoreGetItemQuerySchema,
45 success: { data: guiStoreGetItemResponseSchema },
46 errors: { [ErrorCode.VALIDATION_FAILED]: {} },
47 description: 'Read a value by key (mirrors localStorage.getItem).',
48 tags: ['gui-store'],
49 },
50 async (req, reply) => {
51 const value = await ix.invokeFunction((a) =>
52 a.get(IGuiStoreService).getItem(req.query.key),
53 );
54 reply.send(okEnvelope({ value }, req.id));
55 },
56 );
57 app.get(
58 getItemRoute.path,
59 getItemRoute.options,
60 getItemRoute.handler as Parameters<GuiStoreRouteHost['get']>[2],
61 );
62
63 const setItemRoute = defineRoute(
64 {
65 method: 'POST',
66 path: '/gui/store/setItem',
67 body: guiStoreSetItemBodySchema,
68 success: { data: z.null() },
69 errors: { [ErrorCode.VALIDATION_FAILED]: {} },
70 description: 'Write a value by key (mirrors localStorage.setItem).',
71 tags: ['gui-store'],
72 },
73 async (req, reply) => {
74 await ix.invokeFunction((a) =>
75 a.get(IGuiStoreService).setItem(req.body.key, req.body.value),
76 );
77 reply.send(okEnvelope(null, req.id));
78 },
79 );
80 app.post(
81 setItemRoute.path,
82 setItemRoute.options,
83 setItemRoute.handler as Parameters<GuiStoreRouteHost['post']>[2],
84 );
85
86 const removeItemRoute = defineRoute(
87 {
88 method: 'POST',
89 path: '/gui/store/removeItem',
90 body: guiStoreRemoveItemBodySchema,
91 success: { data: z.null() },
92 errors: { [ErrorCode.VALIDATION_FAILED]: {} },
93 description: 'Delete a value by key (mirrors localStorage.removeItem).',

Callers 1

registerApiV1RoutesFunction · 0.90

Calls 11

defineRouteFunction · 0.90
okEnvelopeFunction · 0.90
invokeFunctionMethod · 0.65
getItemMethod · 0.65
getMethod · 0.65
sendMethod · 0.65
setItemMethod · 0.65
postMethod · 0.65
removeItemMethod · 0.65
clearMethod · 0.65
lengthMethod · 0.65

Tested by

no test coverage detected