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

Function appOf

packages/server/test/sessions.e2e.test.ts:94–115  ·  view source on GitHub ↗
(r: RunningServer)

Source from the content-addressed store, hash-verified

92}
93
94function appOf(r: RunningServer): {
95 inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>;
96} {
97 const app = r.services.invokeFunction((a) => {
98 const gw = a.get(IRestGateway);
99 return gw.app as unknown as {
100 inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>;
101};
102 });
103 // Auto-attach the fixed bearer token so the M5.1 auth hook passes. A
104 // caller-supplied `authorization` header wins, so explicit token tests keep
105 // working; every other header (Range, content-type, …) is preserved.
106 return {
107 inject(req: unknown) {
108 const q = req as { headers?: Record<string, string | string[] | undefined> };
109 return app.inject({
110 ...q,
111 headers: { authorization: 'Bearer test-token', ...q.headers },
112 });
113 },
114 };
115}
116
117function envelopeOf<T>(body: unknown): { code: number; msg: string; data: T | null; request_id: string; details?: unknown } {
118 return body as { code: number; msg: string; data: T | null; request_id: string; details?: unknown };

Callers 1

Calls 2

invokeFunctionMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected