Skip to content

NeoSOFT-Technologies/node-rest

Repository files navigation

Multitenant Solution(IAM) CI

A multitenancy starter project using Node.js, NestsJS, Express, and MySQL.

By running one command, you will get a production-ready Node.js app installed and configured on your machine. The project has microservice architecture with many built-in features in the skeleton, including continuous integration, docker support, authentication & authorization, request validation, ORM support, API documentation, system logger, etc. To learn more about its features, check out the following list.

Description

  • Nest framework TypeScript starter repository.

  • Nest provides a level of abstraction above these common Node.js frameworks (Express/Fastify) but also exposes their APIs directly to the developer. This allows developers the freedom to use the myriad of third-party modules which are available for the underlying platform.

  • There are superb libraries, helpers, and tools that exist for Node (and server-side JavaScript), none of them effectively solve the main problem of — Architecture.

Table of Contents

Features

  • Quick start
  • Integrated ESLint, Prettier and Husky
  • Simple and Standard scaffolding
  • Production-Ready Skeleton
  • Followed SOLID Principles
  • Microservice Architecture: using NestJS
  • Multitenant APIs - Database Per Tenant: API documentation
  • Authentication and authorization: using Keycloak
  • Validation: request data validation using Nest JS Pipe
  • Logging: using winston
  • Testing: unit tests using Jest
  • Error handling: centralized error handling mechanism Exception Filter
  • ORM support: database integration with TypeORM
  • API documentation: with swagger
  • Process management: advanced production process management using PM2
  • Dependency management: with npm
  • Environment variables: using dotenv and cross-env
  • CORS: Cross-Origin Resource-Sharing enabled using cors
  • CI: Continuous integration with Travis CI
  • Docker support
  • Git hooks: with husky and lint-staged
  • Linting: with ESLint and Prettier
  • Editor config: consistent editor configuration using EditorConfig

Getting started

Prerequisites

Setup

To get started, clone the repository to your local computer. Use the following command to run in your terminal.

Clone The Application

// clone the application
$ git clone https://github.com/NeoSOFT-Technologies/node-rest.git

Install The Dependencies

Next, install the packages that are required for this project.

# Install the required npm modules in root repo
$ npm install

Running the app

# docker
$ docker-compose up #--build

The output of the above command should be shown as below.

Docker-compose-up

Project Structure

In a TypeScript project, it's best to have separate source and distributable files. TypeScript (.ts) files live in your src folder and after compilation are output as JavaScript (.js) in the dist folder. The test and views folders remain top level as expected.

Please find below a detailed description of the app's folder structures:

Note! Make sure you have already built the app using npm run build

Name Description
.github Contains GitHub settings and configurations, including the GitHub Actions workflows
.husky Contains and manages git hooks
node_modules Contains all your npm dependencies
${service-name}/node_modules Contains all your npm dependencies of microservices
${service-name}/dist Contains the distributable (or output) from your TypeScript build. This is the code you ship
${service-name}/src Contains your source code that will be compiled to the dist dir
${service-name}/src/config Here you will find all the environment configuration necessary to access the application
${service-name}/src/${module_name}/ Microservice defined group of files/source
${service-name}/src/transport Information about Microservice communication layer
${service-name}/src/${module_name}/dto/ DTO (Data Transfer Object) Schema, Validation
${service-name}/src/${module_name}/entities/ Entities belongs to that Microservice
${service-name}/src/${module_name}/db/ Database module for Typeorm
${service-name}/src/${module_name}/module_name.controllers.ts Controller belongs to that Microservice
${service-name}/src/${module_name}/module_name.module.ts Module belongs to that Microservice
${service-name}/src/main.ts Entry point to your backend app
${service-name}/test Contains your tests. Separate from source because there is a different build process.
config/.env API keys, tokens, passwords, database URI. Clone this, but don't check it in to public repos.
package.json File that contains npm dependencies
tsconfig.json Config settings for compiling server code written in TypeScript
tsconfig.build.json Config settings for compiling tests written in TypeScript
.eslintrc Config settings for ESLint code style checking
.eslintignore Config settings for paths to exclude from linting

List of Services and Ports

Sr No. Name of the Services Port Number
1. Multi-Tenancy-Rest-Service 5000
2. Tenant Registeration Service 8875
3. Tenant Provision Service 8878
4. Tenant Master Service 8847
5. Tenant Config Service 8848
6. MySQL Database 3306
7. Keycloak Server 8080
8. Demo Mailer Server 1025 & 8025

Documentation

1. Setting up project on VM

Following are the steps to set-up this repository on Virtual Machine.

  • Install Remote Desktop Application (Eg For Linux it is Remmina) in your Machine.
  • Launch the remote desktop which will look like this.

Selection_177

  • Enter the IP address.
  • Once the IP address is verified the following screen will appear.
  • Enter the required credentials i.e admin and password, and then the VM is connected.
  • Open any browser and then clone the repository of node-rest boilerplate by copy pasting the link https://github.com/NeoSOFT-Technologies/node-rest
  • Open the Terminal in the node-rest directory and then type the following command - docker-compose up and the application will start.
  • Open the browser and hit the following URL: http://localhost:5000/api/docs and the Swagger UI will be displayed.

2. Microservices

3. Consuming Microservices

4. Metrics

Video Tutorials

The Below list is the demonstration Videos of the various features of the project.

Contributing To This Project

Contributions are welcome from anyone and everyone. We encourage you to review the guiding principles for contributing

Issues and Discussions

Miscellaneous

Stay in touch