| import { AsyncLocalStorage } from 'async_hooks'; | |
| export const tenantContext = new AsyncLocalStorage<{ organizationId: string }>(); | |
| export const runWithTenant = <T>(organizationId: string, fn: () => T): T => { | |
| return tenantContext.run({ organizationId }, fn); | |
| }; | |
| export const getOrganizationId = (): string | undefined => { | |
| return tenantContext.getStore()?.organizationId; | |
| }; | |