MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeSelfHostTestApp

Function makeSelfHostTestApp

apps/host-selfhost/src/testing/test-app.ts:176–224  ·  view source on GitHub ↗
(
  options: MakeSelfHostTestAppOptions,
)

Source from the content-addressed store, hash-verified

174}
175
176export const makeSelfHostTestApp = async (
177 options: MakeSelfHostTestAppOptions,
178): Promise<SelfHostTestHandler> => {
179 const config = loadConfig();
180
181 const dbHandle = await createSelfHostDb({
182 path: options.dbPath ?? config.dbPath,
183 namespace: SELF_HOST_NAMESPACE,
184 version: SELF_HOST_SCHEMA_VERSION,
185 });
186
187 const sessionStore = makeSelfHostMcpSessionStore(dbHandle);
188
189 const { toWebHandler } = ExecutorApp.make({
190 plugins: selfHostPlugins,
191 providers: {
192 identity: options.identity,
193 db: SelfHostDbProvider,
194 engine: { codeExecutor: SelfHostCodeExecutorProvider },
195 mcp: {
196 auth: stubMcpAuth,
197 sessions: selfHostMcpSessions(sessionStore),
198 reporter: selfHostMcpReporter,
199 },
200 plugins: { provider: SelfHostPluginsProvider, config: SelfHostHostConfig },
201 errorCapture: ErrorCaptureLive,
202 },
203 extensions: {
204 routes: [
205 HttpApiSwagger.layer(composePluginApi(selfHostPlugins).prefix("/api"), { path: "/docs" }),
206 ],
207 },
208 config: { mountPrefix: "/api", failure: textFailureStrategy },
209 // The test identity is boot-scoped exactly as production's is: no
210 // requestScoped layer, so the execution middleware leaves IdentityProvider
211 // residual and `provideMerge(boot)` supplies it.
212 boot: Layer.merge(Layer.succeed(SelfHostDb)(dbHandle), options.identity),
213 });
214
215 const web = toWebHandler();
216 return {
217 handler: web.handler,
218 dispose: async () => {
219 await web.dispose();
220 await sessionStore.close();
221 await dbHandle.close();
222 },
223 };
224};

Callers 2

boot.test.tsFile · 0.85

Calls 6

loadConfigFunction · 0.90
createSelfHostDbFunction · 0.90
composePluginApiFunction · 0.85
disposeMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected