Skip to content

Latest commit

 

History

History
23 lines (19 loc) · 746 Bytes

File metadata and controls

23 lines (19 loc) · 746 Bytes

7. Problem: Express Middleware

Problem Statement: Implement an Express middleware function that logs the timestamp and the HTTP method of every incoming request to the server.

Function Signature:

/**
 * Express middleware to log incoming requests
 * @param {Object} req - Express request object
 * @param {Object} res - Express response object
 * @param {Function} next - Express next function
 */
function requestLoggerMiddleware(req, res, next) {
  // Your implementation here
}

Expected Output: Log entries in the server console should be in the format: {timestamp} - {HTTP method} request received.

Test Cases:

  1. Any incoming request should trigger the middleware and log the appropriate message.