Quick start
Creating an App
npx create-quick-node-app my-app
cd my-app
npm run dev (To run in development)
Getting started
MNode is a basic skeleton written in JavaScript with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. MNode takes the pain out of development by easing common tasks used in many applications. MNode is accessible, powerful, and provides tools required for large, robust applications.
A ready-to-use boilerplate for REST API Development with Node.js, Express, and MongoDB.
This README would normally document whatever steps are necessary to get your application up and running.
Advertise for Job/Work Contract
I am open for a good job or work contract. You can contact me directly on my email (bera.ujjwal@hotmail.com) or on my skype ujjwalbera
.
Buy me a Coffee
Hi! I'm Ujjwal Bera, I'm an open source enthusiast and devote my free time to building projects in this field.
I'm the creator and maintainer of MNode and SNode.
I'm doing my best to provide you a good experience when using my apps, so if you like what I'm doing and wish to say "thanks!", You can appreciate me or my hard work and time spent to create this helpful structure with buying me a coffee.
Features
- Multiple environment ready (development, production)
- Basic Authentication (Register/Login/Forgot Password)
- Profile Management (Pull Profile Details/Update Profile/Change Password)
- Email helper ready just import and use.
- Integrated Authorization.
- Integrated ACL with User permission & Role Permission.
- Integrated with Neo4J, Redis and Kafka.
Software Requirements
- Node.js 16.20+ (Recommended 18.18)
- MongoDB 5+ (Recommended 6.0)
How to run
Database cleaning and seeding samples
There are 3 available commands for this: fresh
, clean
and seed
.
npm run command
-
fresh
cleans and then seeds the database with dynamic data. -
clean
cleans the database. -
seed
seeds the database with dynamic data.
Running API server locally
npm run dev
You will know server is running by checking the output of the command npm run dev
✔ Bootstrapping Application
✔ Mode: YOUR_APP_MODE
✔ Port: YOUR_APP_PORT
✔ Connected to database with YOUR_DB_CONNECTION_STRING
✔ Mapping Routes
✔ Application Started
Note: YOUR_APP_MODE
is your application running mode that you have set up in .env
file, YOUR_APP_PORT
is your node port that you have set up in .env
file for run node app and YOUR_DB_CONNECTION_STRING
will be your MongoDB connection string.
Creating new models
If you need to add more models to the project just create a new file in /models/
. To create a new model you can use below command.
node cli make:model product
product is your model here
Creating new routes
If you need to add more routes to the project just create a new file in /routes/
for web and add in /routes/api
for api. It will be loaded dynamically. To create a new model you can use below command.
node cli make:route product
Creating new controllers
If you need to add more controllers to the project just create a new file in /app/controllers/
and use them in the routes. To create a new model you can use below command.
node cli make:controller product
product is your controller here
Helpfull Commands from CLI to create files (recommended)
node cli make:controller product
node cli make:model product
node cli make:service product
node cli make:validation product
node cli make:middleware product
node cli make:route product
node cli make:testCase product
Authorization & ACL setting
Authorization setting example in router
router.get('/users', [authMiddleware.verifyToken], usersController.userStore);
ACL setting example in router
router.post(
'/users',
[authMiddleware.verifyToken, aclMiddleware.hasPermission('read', 'users')], // "read" as action, "users" as resource
usersController.userStore,
);
Tests
Running Test Cases
npm test
Creating new tests
If you need to add more test cases to the project just create a new file in /test/
and run the command.
Bugs or improvements
Every project needs improvements, Feel free to report any bugs or improvements. Pull requests are always welcome.