Multi Tenancy with NestJS async-hooks

Note: the async_hooks feature is still in stability state 1. Thus, no backwards compatibility or guaranteed integrity with npm is guaranteed for future releases. Use with caution! In the post Multi Tenancy with Nestjs I explained an approach using NestJS factory providers. As this changes the scope of all dependent classes to REQUEST, it may lead to a major performance decrease. Each request would generate new instances of each class in injection chains which have the Tenant injected....

December 25, 2020 · 3 min · Fabian Isele

Multi Tenancy with NestJS

Intro This post describes one approach to multi-tenancy with NestJS using Postgres Row Level Security (RLS). First, you’ll read about the necessary Postgres configuration steps. Second, the extraction of the tenant from a request is explained with code snippets and examples. The full project ist available here at Github First things first: What is multi-tenancy? Multi-tenancy is an approach of splitting a SaaS product virtually into tenants. Thus, one instance of the SaaS can serve multiple customers without any interference of their individual data....

December 13, 2020 · 7 min · Fabian Isele