/multi-tenant-node-app

POC of Multi-Tenant REST Application Built on top of NodeJS

Primary LanguageJavaScript

multi-tenant-node-app

What is this?

This is a proof-of-concept (POC), multi-tenant RESTful Web Services application built on top of NodeJS.

Get Started

  • Install dependencies.
npm install
  • Verify the Database configuration in config/config.json.
  • Create DB using Sequelize.
npx sequelize-cli db:create
  • Run migrations on the main database.
npx sequelize-cli db:migrate
  • Start the application.
npm start
  • Perform API requests.

APIs

HTTP Headers

  • For APIs other than Signup and Authentication, pass the JWT Token in the Authorization header of the request.
Authorization: Bearer <JWT Token>
  • For APIs other than Signup, pass the Tenant ID in the X-TENANT-ID custom header of the request.
X-TENANT-ID: <Tenant ID>

Signup

  • POST /api/v1/accounts/signup
{
  "name": "Alphabet",
  "domain": "alphabet.com",
  "firstName": "John",
  "lastName": "Doe",
  "email": "johndoe@alphabet.com",
  "password": "5f4dcc3b5aa765d61d8327deb882cf99"
}

Authentication

  • POST /api/v1/auth/login
{
  "email": "johndoe@google.com",
  "password": "5f4dcc3b5aa765d61d8327deb882cf99"
}

Organizations

  • GET /api/v1/organizations

  • GET /api/v1/organizations/:organizationId

  • POST /api/v1/organizations

{
  "name": "Google",
  "domain": "google.com"
}
  • DELETE /api/v1/organizations/:organizationId

Users

  • GET /api/v1/users

  • GET /api/v1/users/:userId

  • POST /api/v1/users

{
  "firstName": "John",
  "lastName": "Doe",
  "email": "johndoe@google.com",
  "password": "5f4dcc3b5aa765d61d8327deb882cf99"
}
  • DELETE /api/v1/users/:userId

Libraries