公共 API 参考(@saas/contracts + @core/saas-kit + apps/api 对外接口)
    Preparing search index...

    逐请求解析活跃租户并绑定至 AsyncLocalStorage(global-tenancy §9.3 / FR-2)。

    Resolves the active tenant for each request and binds it to AsyncLocalStorage (global-tenancy §9.3 / FR-2). Reads the trusted session (user id + activeOrganizationId) through the core-owned RequestSessionReader port — no Better Auth / @app/modules/auth import crosses into tenancy core (§9.5.4①B · P1b). Downstream guards / services read the bound context via TenantIsolationService.

    The port's read already short-circuits public / auth / bypass routes (and any request without a session cookie) to null, so this adds a session lookup only where one can exist. Failures degrade to "no tenant" rather than throwing (enforcement is S2).

    Implements

    • NestMiddleware
    Index
    • 解析会话→(封禁/失能 fail-closed 后)绑定租户作用域·随后放行 next。

      Parameters

      • req: any

        入站请求(读会话 + x-workspace-id 头)

      • _res: any

        响应(本中间件不写响应·仅透传)

      • next: () => void

        下游继续执行

      Returns void