@forinda/kickjs-multi-tenant
v1.3.2
Published
Multi-tenancy helpers for KickJS — tenant resolution, scoped DI, and database routing
Maintainers
Keywords
Readme
@forinda/kickjs-multi-tenant
Multi-tenancy helpers for KickJS — tenant resolution, scoped DI, and database routing.
Install
# Using the KickJS CLI (recommended)
kick add multi-tenant
# Manual install
pnpm add @forinda/kickjs-multi-tenantFeatures
TenantAdapter— lifecycle adapter that resolves tenant from requestsTENANT_CONTEXTtoken for injecting tenant info via DI- Pluggable resolution strategies: header, subdomain, path, or custom
- Scoped DI for per-tenant service instances
Quick Example
import { TenantAdapter, TENANT_CONTEXT, type TenantInfo } from '@forinda/kickjs-multi-tenant'
import { Inject, Service } from '@forinda/kickjs-core'
bootstrap({
modules,
adapters: [
new TenantAdapter({
strategy: 'header',
headerName: 'X-Tenant-ID',
}),
],
})
// Access tenant in any service
@Service()
class DataService {
@Inject(TENANT_CONTEXT) private tenant!: TenantInfo
async getData() {
return this.repo.findByTenant(this.tenant.id)
}
}Documentation
License
MIT
