Skip to content

feat: add request/response logging middleware#154

Open
Nishal77 wants to merge 3 commits into
metacall:masterfrom
Nishal77:feat/request-logging-middleware
Open

feat: add request/response logging middleware#154
Nishal77 wants to merge 3 commits into
metacall:masterfrom
Nishal77:feat/request-logging-middleware

Conversation

@Nishal77
Copy link
Copy Markdown

Summary

Adds src/middleware/requestLogger.ts logs every HTTP request on response finish with method, path, status code, and duration in ms. Uses process.hrtime.bigint() for nanosecond precision. No new dependencies.

Related issue

Fixes #153

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Chore / CI
  • Breaking change

How to test

  1. Checkout the branch
  2. Run npm ci
  3. Run npm start
  4. In another terminal: curl http://localhost:9000/health
  5. Check server terminal for: [GET] /health 200 1.23ms

Checklist

  • I have read the contributing guidelines
  • I added tests that prove my fix is effective or that my feature works
  • I updated documentation if necessary

Notes for reviewers

  • Registered in src/api.ts immediately after express.json() and express.urlencoded() so it runs before all routes
  • Uses res.on('finish') — logs after response sent, never blocks request handling
  • No colors, no ANSI codes, plain text only

Release notes

All incoming requests now logged to stdout with method, path, status, and duration in ms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add request/response logging middleware

1 participant