/nodejs-starter-kit

A template for building production-ready RESTful APIs and dashboard

Primary LanguageJavaScriptMIT LicenseMIT

Getting Started

First of all, let me admit this article is inspired to develop this project. Uncle Bob's famous Clean Architecture is a way to write resilient software.

I am introduced a simple API template for backend developers using clean architecture based on express application. When you choose Node.js + SQL (MySQL) or NoSQL (MongoDB) as your backend stack, the template is based on the following frameworks and libraries to completely cover a project that is ready for production.

Demo Video

introduce.mp4

Express

  • a powerful and flexible framework that makes it easy to build web applications and APIs using Node.js. Its minimalist approach and large ecosystem make it a popular choice for developers who want to build scalable and maintainable web applications.

Sequelize

  • an Object-Relational Mapping (ORM) library for Node.js, which allows you to work with relational databases such as MySQL, PostgreSQL, and SQLite using JavaScript syntax.

Mongoose

  • a powerful and flexible ODM library for MongoDB and Node.js that provides a rich set of tools for working with data. Its schema-based approach, data validation tools, and powerful

Bootstrap

  • a popular front-end framework for building responsive and mobile-first web applications. It was originally developed by Twitter and is now maintained by the open-source community.

Passport

  • an open-source authentication middleware for Node.js. It provides a simple and modular approach to authentication that makes it easy to add user authentication to web applications.

Multer

  • a popular package that provides middleware for handling multipart/form-data in Node.js. It's commonly used in web applications to handle file uploads from users.

JWT

  • in the context of Node.js, the jsonwebtoken package is a popular npm package that provides a simple way to create and verify JWTs.

Mocha

  • a testing framework for Node.js applications. It's designed to provide a simple and flexible way to write and run tests, with support for a variety of testing styles and frameworks.

The followings must be pre-installed on your machine:

  • Node.js,
  • MongoDB,
  • Redis

Clone itemplate repository

git clone https://github.com/waiphyo285/nodejs-starter-kit.git

Visit Public Postman Collection

https://documenter.getpostman.com/view/10018411/2s83mbr5iK

Navigate root directory and install dependencies

npm install

Copy .env.example to .env

cp .env.example .env

Run app and then go to browser

npm run dev
localhost:6060

TDD ./../.spec.js in controllers

npm run test

CLI commands in src/cli

node index
node index --index
node index --show=623210497fc2cb28840d1448

_Note: this application is different to the Clean Architecture diagram above but attempts to achieve the same outcome.