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

Function makeSelfHostApiHandler

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

Source from the content-addressed store, hash-verified

189// uses for Workers). The self-host server (serve.ts) binds `AppLayer` to a
190// listening socket instead. We wrap `dispose` to also close the DB / MCP store.
191export const makeSelfHostApiHandler = async (
192 options: MakeSelfHostAppOptions = {},
193): Promise<SelfHostApiHandler> => {
194 const { toWebHandler, betterAuth, closeDb } = await makeSelfHostApp(options);
195 const web = toWebHandler();
196 return {
197 handler: async (request) => {
198 const location = await oauthCallbackSignInRedirectLocation(request, betterAuth.auth);
199 if (location) return new Response(null, { status: 302, headers: { location } });
200 return web.handler(request);
201 },
202 dispose: async () => {
203 await web.dispose();
204 await closeDb();
205 },
206 };
207};

Calls 3

makeSelfHostAppFunction · 0.85
disposeMethod · 0.80

Tested by

no test coverage detected