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

Function appOf

packages/server/test/connections.e2e.test.ts:73–94  ·  view source on GitHub ↗

Pull the Fastify instance off the running server for hermetic REST injects.

(r: RunningServer)

Source from the content-addressed store, hash-verified

71
72/** Pull the Fastify instance off the running server for hermetic REST injects. */
73function appOf(r: RunningServer): {
74 inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>;
75} {
76 const app = r.services.invokeFunction((a) => {
77 const gw = a.get(IRestGateway);
78 return gw.app as unknown as {
79 inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>;
80};
81 });
82 // Auto-attach the fixed bearer token so the M5.1 auth hook passes. A
83 // caller-supplied `authorization` header wins, so explicit token tests keep
84 // working; every other header (Range, content-type, …) is preserved.
85 return {
86 inject(req: unknown) {
87 const q = req as { headers?: Record<string, string | string[] | undefined> };
88 return app.inject({
89 ...q,
90 headers: { authorization: 'Bearer test-token', ...q.headers },
91 });
92 },
93 };
94}
95
96function wsUrl(http: string): string {
97 return http.replace(/^http:\/\//, 'ws://') + '/api/v1/ws';

Callers 1

Calls 2

invokeFunctionMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected