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.
-
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.
- Features
- Getting started
- Project Structure
- Documentation
- Video Tutorials
- Contributing To This Project
- Issues and Discussions
- Miscellaneous
- Stay in touch
- 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
- Node https://nodejs.org/en/ use the LTS version
- NPM
- Docker https://www.docker.com/
- Install Docker Desktop for MAC: https://docs.docker.com/docker-for-mac/install/
- Install Docker Desktop for Windows: https://docs.docker.com/docker-for-windows/install/
- Docker Compose
- NestJS CLI https://nestjs.com/
To get started, clone the repository to your local computer. Use the following command to run in your terminal.
// clone the application
$ git clone https://github.com/NeoSOFT-Technologies/node-rest.gitNext, install the packages that are required for this project.
# Install the required npm modules in root repo
$ npm install# docker
$ docker-compose up #--buildThe output of the above command should be shown as below.
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 |
| 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 |
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.
- 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-restdirectory and then type the following command -docker-compose upand the application will start. - Open the browser and hit the following URL:
http://localhost:5000/api/docsand the Swagger UI will be displayed.
- Tenant Registration Service
- Tenant Master Service
- Tenant Provisioning Service
- Tenant Configuration Service
- Clone & Installation Setup
- Start the application with Docker Containers
- All micro services Introduction
- Swagger Demo - 1
Swagger Demo - 2
Swagger Demo - 3 - Postman Demo
Contributions are welcome from anyone and everyone. We encourage you to review the guiding principles for contributing
- Website - https://www.neosofttech.com/
- Twitter - @neosofttech
- Meetup - https://www.meetup.com/neosoft-technologies/
- Medium - https://medium.com/@neosofttech-technologies-blog
- GitHub - https://github.com/NeoSOFT-Technologies
- Discord - NodeJS

