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