Skip to content

basalt / tenancy/src / findByVerifiedDomain

Function: findByVerifiedDomain() ​

> findByVerifiedDomain<T>(customDomains, find): (domain) => Promise<T | null>

Defined in: tenancy/src/custom-domains.ts:537

Build a findByDomain that resolves ONLY verified custom domains, by looking the domain up via CustomDomains.tenantOf then loading the tenant. Wire this into your TenantSource so a forged/unverified Host header can never resolve to a tenant:

ts
const source: TenantSource = {
  find: (id) => db.tenant.find(id),
  findByDomain: findByVerifiedDomain(customDomains, (id) => db.tenant.find(id)),
}

Type Parameters ​

T ​

T

Parameters ​

customDomains ​

CustomDomains

find ​

(tenantId) => Promise<T | null>

Returns ​

(domain) => Promise<T | null>

Released under the MIT License.