-
Notifications
You must be signed in to change notification settings - Fork 23
Home
In Saas applications; multitenancy is a mode of operation where multiple independent instances share the same environment. In plain English, it is when multiple tenants and businesses use the same Saas application.
I will not cover how to design a multitenancy application in this article, however, you can read about it in detail here: What is Multi-Tenant Architecture? By Andy Patrizio
From here on, we are going to work on an example about the multi-tenants using multiple Databases and microservices architecture.
We will focus on ROLE-BASED ACCESS CONTROL with multi-database and will use two databases -MySQL and MongoDB- for each tenant: We will use sample web services to test the flow, for example creating users, sending and receiving notifications... etc.
From nest js: nest (NestJS) is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with and fully supports TypeScript (yet still enables developers to code in pure JavaScript), and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
You will need to install Node.js, and it must be version 10.13 or higher. I will install v12 LTS and npm. I recommend that you use nvm to install node.js
You need to install nest cli using npm:
npm install -g @nestjs/cli
then create a new nest.js project:
nest new multi_tenant
If you encountered an error during the installation like:
npm ERR! invalid json response body at https://registry.npmjs.org/ajv reason: Unexpected end of JSON input.
You can use this to fix it:
npm cache clean --force