A simple Express.js backend project demonstrating how to build and use a custom request logging middleware.
This project focuses on understanding how middleware works in Express.js and how to log every incoming HTTP request.
The middleware captures:
- request time
- HTTP method
- request URL
- Node.js
- Express.js
- Nodemon (development)
express-project-05-request-logger-middleware
│
├─ src
│ ├─ controllers
│ │ └─ home.controller.js
│ │
│ ├─ middleware
│ │ └─ requestLogger.middleware.js
│ │
│ └─ routes
│ └─ home.routes.js
│
├─ index.js
├─ package.json
├─ package-lock.json
└─ .gitignore
Clone the repository
git clone https://github.com/a2rp/express-project-05-request-logger-middleware.git
cd express-project-05-request-logger-middlewareInstall dependencies
npm installDevelopment mode using nodemon
npm run devServer will run at
http://localhost:1198
Returns a simple JSON response.
Example response
{
"message": "Request Logger Middleware API is running"
}Every request will be logged in the console.
Example log
[2026-03-17T10:10:10.345Z] GET /
This shows:
- request timestamp
- HTTP method
- requested URL
By building this project you learn:
- how Express middleware works
- how to intercept incoming requests
- how to log request information
- how middleware fits into the request lifecycle
Ashish Ranjan
Follow me
- GitHub: https://github.com/a2rp
- Portfolio: https://www.ashishranjan.net
- LinkedIn: https://www.linkedin.com/in/aashishranjan
- Facebook: https://www.facebook.com/theash.ashish/
