Skip to content

@venturekit-pro/tenancy API

FunctionSignatureDescription
createTenantContext(options) => TenantContextCreate a tenant context
getCurrentTenant(ctx: RequestContext) => TenantContext | nullGet current tenant from request context
resolveTenant(event, strategy) => TenantContextResolve tenant from request
FunctionSignatureDescription
createTenantMiddleware(options: { strategy: string }) => MiddlewareCreate tenant resolution middleware
createQuotaMiddleware(options?) => MiddlewareCreate quota enforcement middleware
checkQuotas(tenantId: string, quotas: Record<string, QuotaDef>) => Promise<void>Check quotas programmatically

Tenant-related types are exported from ./types/index.js, including tenant configuration, resolution strategies, quota definitions, and isolation settings.

Manages tenant context for the current request.

ClassStatusDescription
TenantNotFoundError404Tenant could not be resolved
TenantSuspendedError403Tenant is suspended
TenantInactiveError403Tenant is inactive
QuotaExceededError429Tenant quota exceeded