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

Function makeSelfHostApiHandler

apps/host-selfhost/src/app.ts:181–197  ·  view source on GitHub ↗
(
  options: MakeSelfHostAppOptions = {},
)

Source from the content-addressed store, hash-verified

179// uses for Workers). The self-host server (serve.ts) binds `AppLayer` to a
180// listening socket instead. We wrap `dispose` to also close the DB / MCP store.
181export const makeSelfHostApiHandler = async (
182 options: MakeSelfHostAppOptions = {},
183): Promise<SelfHostApiHandler> => {
184 const { toWebHandler, betterAuth, closeDb } = await makeSelfHostApp(options);
185 const web = toWebHandler();
186 return {
187 handler: async (request) => {
188 const location = await oauthCallbackSignInRedirectLocation(request, betterAuth.auth);
189 if (location) return new Response(null, { status: 302, headers: { location } });
190 return web.handler(request);
191 },
192 dispose: async () => {
193 await web.dispose();
194 await closeDb();
195 },
196 };
197};

Calls 3

makeSelfHostAppFunction · 0.85
disposeMethod · 0.80

Tested by

no test coverage detected