(
options: MakeSelfHostAppOptions = {},
)
| 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. |
| 191 | export 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 | }; |
no test coverage detected