(
options: MakeSelfHostAppOptions = {},
)
| 155 | // uses for Workers). The self-host server (serve.ts) binds `AppLayer` to a |
| 156 | // listening socket instead. We wrap `dispose` to also close the DB / MCP store. |
| 157 | export const makeSelfHostApiHandler = async ( |
| 158 | options: MakeSelfHostAppOptions = {}, |
| 159 | ): Promise<SelfHostApiHandler> => { |
| 160 | const { toWebHandler, betterAuth, closeDb } = await makeSelfHostApp(options); |
| 161 | const web = toWebHandler(); |
| 162 | return { |
| 163 | handler: async (request) => { |
| 164 | const location = await oauthCallbackSignInRedirectLocation(request, betterAuth.auth); |
| 165 | if (location) return new Response(null, { status: 302, headers: { location } }); |
| 166 | return web.handler(request); |
| 167 | }, |
| 168 | dispose: async () => { |
| 169 | await web.dispose(); |
| 170 | await closeDb(); |
| 171 | }, |
| 172 | }; |
| 173 | }; |
no test coverage detected