Member-only story

MERN — ExpressJS Fundamentals

kelvinBz

Fundamentals

Express.js is a popular web application framework for Node.js that simplifies building web applications and APIs.

  • Middleware: Functions that access the request and response objects to modify, add data, or trigger other functions.
  • Router: A mini-app that only deals with routing. It can have its middleware and routing logic.
  • Handler: A function that handles a specific route or endpoint.
  • Error Middleware: Middleware functions that have an extra parameter for error handling.

Middleware

A request-response cycle in Express.js involves a series of middleware functions that execute sequentially. Each middleware can modify the request and response objects, end the request-response cycle, or call the next middleware in the stack.

Middleware Functions: Execute sequentially, each modifying the request/response objects or ending the request-response cycle. Examples: Logging, authentication, parsing data

const express = require('express');
const app = express();
app.use((req, res, next) => { // ( 🔴, 🔵, 🚪)…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

kelvinBz
kelvinBz

Written by kelvinBz

Software Engineer | MongoDB, AWS, Azure Certified Developer

No responses yet

Write a response