Skip to content

tejaswitandel/tttt

Repository files navigation

MVC NodeJS,Mongoose,Express Project

supported version of nodejs-15.13.0 supported version of mongoose-4.0

This is a template of Web application, developed using MVC pattern with Node.js, ExpressJS, and Mongoose ODM. Basic boilerplate for web applications, built on Express.js using the Model–View–Controller architectural pattern. The views are created with the Embedded JavaScript template (EJS) view engine. A MongoDB database is used for data storage, with object modeling provided by Mongoose.

initial

  • Configure a basic server in app.js.
  • Organize the routes with Express Router.
  • Use the mainRoutes in app as middleware.
  • Set a final use after the routes, to display a 404 message for the unhandled requests. 1.Install needed Node.js modules: $ npm install 2.execute server: $ npm start

folder structure:

 --project
   --project_folder
           --config
           --controller
           --jobs
           --logs
           --middleware
           --model
           --postman
           --public
           --routes
           --services
           --utils
           --views
           --app.js
		   --.env
		   --.gitignore
		   --.eslintrc.js
   --project_folder.zip

app.js

  • entry point of application.

config

  • passport strategy for all platforms.
  • based on Auth Model - authentication files has been generated.
  • Auth constant File that has authentication configuration constants
  • Used .env file and configure the db connection string to use in the project.

controller

  • includes controller files per model

  • Controllers are separated per Platform

        -controller
              -admin
                -modelController.js
              -device
                -modelController.js
              -desktop
                -modelController.js
              -client
                -modelController.js
    

jobs

  • Cron jobs related Files and configuration

logs

  • Log file

middleware

  • User authentication Middleware based on Roles and permission for Routes' access
  • Custom Policy files

models

  • Mongoose Models , as per user defined schema

postman

  • Postman collection File for Platform based APIs that are generated.
  • Import this JSON in Postman to test the APIs.

public

  • You can add static files like like images, pdf etc.

routes

  • based on platform,separate folder is generated,within those folders model wise route files are that has model crud APIs' routes.
  • index.js file, main file which includes all platform routes.
  • added index files in app.js to access the routes of the application.

services

 	-jobs
   		-cron job services
 	-auth.js
   		-Logic for JWT Tokenization for user to login into Application using username and password along with otp if required.

utils

     -validation
 		   -joi validations files.
 		   -files are separated by models.
 	 -common.js
   		   -converted object to enum function.
 	 -dbService.js
   		 -common Database functionalities
 	  	 -getAllDocuments(find all documents)
 	  	 -updateDocuments(update single documents in db)
 	  	 -deleteDocuments(delete single documents in db)
 	  	 -createDocuments(create single documents in db)
 	  	 -getDocumentByQuery(find single document)
		 -getSingleDocumentById(find by id)
 	  	 -softDelete
 	  	 -findExistData
 	  	 -bulkInsert(insert multiple documents in db)
 	  	 -bulkUpdate(update multiple documents in db)
 	  	 -countDocument
		 -Aggregation
 	 -messages.js
	     -static messages that are sent with response - contains status and Data
      -responseCode.js
	     -codes for responses
      -validateRequest.js
	     -validate schema based on joi validation

views

  • add ejs files

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published