Skip to content

a2rp/express-project-05-request-logger-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-project-05-request-logger-middleware

A simple Express.js backend project demonstrating how to build and use a custom request logging middleware.

Project Goal

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

Tech Stack

  • Node.js
  • Express.js
  • Nodemon (development)

Project Structure

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

Installation

Clone the repository

git clone https://github.com/a2rp/express-project-05-request-logger-middleware.git
cd express-project-05-request-logger-middleware

Install dependencies

npm install

Run the Project

Development mode using nodemon

npm run dev

Server will run at

http://localhost:1198

API Endpoint

GET /

Returns a simple JSON response.

Example response

{
    "message": "Request Logger Middleware API is running"
}

alt text


Middleware Example Output

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

Learning Outcome

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

Author

Ashish Ranjan


Follow me

About

Express.js API demonstrating a custom request logger middleware that logs every incoming HTTP request.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors