is a zero-dependency module that loads environment variables from a .env file into process.env
- MVC is short for Model, View, and Controller.
- It's an architectural pattern that separates an application into three main
logical components Model , view and controller
- Model that part of the application that ( handles || stores )** data** and its related logic
- View that part of the application that represent the presentation of data (UI components).
- Controller is that part of the application that handles the user interaction
Example from daily life :
View = You
Waiter = Controller
Cook = Model
Refrigerator = Data
So, to sum it up:
- Model is data part.
- View is User Interface part.
- Controller is request-response handler.
- routes folder, which will serve as controllers.
- models folder, in which we have a data model.
- views folder, which have our views
resources:
- MVC Tutorial for Beginners: What is, Architecture & Example
- ماهو مبدأ Model View Controller (MVC) ؟ (للمبتدئين)
- Model-View-Controller(MVC) architecture for Node applications
- It's short for Hierarchical Model View Controller
- Separate the app into Modules with MVC pattern
Resources :
- Laravel 5.8 lesson 1 introduction hmvc architectural pattern
- MVC vs HMVC for web application development
-
You can create chainable route handlers for a route path by using app.route().
- single location,
- creating modular routes is helpful
- as is reducing redundancy and typos.
-
For more information about routes, see: Router() documentation.
example of chained route handlers ( route : /api/schools
)
const
express = require('express'),
app = express()
resource = '/api/schools'
// chained route
app.route(`${resource}`)
// Get && search All Schools
.get(schoolController.crud.getSchools)
// add school
.post(schoolController.crud.addSchool)
- express.Router class for creating modular, mountable and chained route handlers
- A router object is an isolated instance of middleware and routes.
example of express route handlers ( route : /api/schools
)
const
express = require('express'),
app = express()
router = express.Router()
resource = '/api/schools'
// chained route
router.route(`${resource}`)
// Get && search All Schools
.get(schoolController.crud.getSchools)
// add school
.post(schoolController.crud.addSchool)
-
It's basically a function which accepts
request
andresponse
objects and anext()
function.app.use(function middleware1(req, res, next) { console.log('Middleware 1') next(); });