(
options: ExecutorAppOptions<
TPlugins,
RDb,
RAcct,
RStrategy,
RBoot,
RReq,
McpExport,
RIdentity,
RMcpAuth
>,
)
| 358 | * same prefixed router, the extension routes, and `provideMerge(boot)`. |
| 359 | */ |
| 360 | export const make = < |
| 361 | const TPlugins extends readonly AnyPlugin[], |
| 362 | RDb, |
| 363 | RAcct, |
| 364 | RStrategy, |
| 365 | RBoot, |
| 366 | RReq = never, |
| 367 | McpExport = undefined, |
| 368 | RIdentity = never, |
| 369 | RMcpAuth = never, |
| 370 | >( |
| 371 | options: ExecutorAppOptions< |
| 372 | TPlugins, |
| 373 | RDb, |
| 374 | RAcct, |
| 375 | RStrategy, |
| 376 | RBoot, |
| 377 | RReq, |
| 378 | McpExport, |
| 379 | RIdentity, |
| 380 | RMcpAuth |
| 381 | >, |
| 382 | ): ExecutorApp<TPlugins, McpExport> => { |
| 383 | const { plugins, providers, config } = options; |
| 384 | |
| 385 | // The execution model is a discriminated union (see `AppProviders`): a host |
| 386 | // either supplies the SCOPED seams (db + plugins + engine -> a fresh |
| 387 | // per-(user, org) executor each request) or a single FIXED executor built once |
| 388 | // at boot (local). `fixedExecution` present on `providers` selects the latter. |
| 389 | const fixedExecution = providers.fixedExecution; |
| 390 | |
| 391 | // ---- a `mountPrefix`-prefixed view of the ambient router --------------- |
| 392 | // Providing it to the API builders makes every API/account route serve under |
| 393 | // the prefix (the router slices it before matching; no hand-written |
| 394 | // stripping). Omitted -> the ambient root router is used. |
| 395 | const prefix = config.mountPrefix; |
| 396 | const prefixedRouter = prefix |
| 397 | ? Layer.effect(HttpRouter.HttpRouter)( |
| 398 | Effect.map(HttpRouter.HttpRouter.asEffect(), (router) => router.prefixed(prefix)), |
| 399 | ) |
| 400 | : undefined; |
| 401 | |
| 402 | // ---- the OAuth callback path, derived from the SAME `mountPrefix` ------ |
| 403 | // The redirect URI the host serves and registers with providers is |
| 404 | // `${webBaseUrl}${mountPrefix}/oauth/callback` — the prefix that mounts the |
| 405 | // API (above) joined with the global `/oauth/callback` route. Deriving it here, |
| 406 | // the one place `mountPrefix` is known, makes the prefix a single source of |
| 407 | // truth: a host states it once via `config.mountPrefix` and cannot drift it |
| 408 | // out of sync with a second hand-written `oauthCallbackPath` (the omission that |
| 409 | // silently 404'd the redirect on every prefix-mounted host). Injected into the |
| 410 | // scoped executor's `HostConfig` below; the fixed model (local) sets its own |
| 411 | // `redirectUri` and is unaffected. |
| 412 | const oauthCallbackPath = `${prefix ?? ""}/oauth/callback`; |
| 413 | |
| 414 | // ---- (2) the ExecutionStackMiddleware --------------------------------- |
| 415 | // The identity seam authenticates; the failure strategy renders; the stack |
| 416 | // Layer + plugin tuple build the per-request executor. The facade ALWAYS builds |
| 417 | // the resolver by reading the neutral `IdentityProvider` tag — no host hand- |
nothing calls this directly
no test coverage detected