Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
Logging http request without authorization/token header express-winston on openapi-generator-cli server stub

I am trying to use express-winston to log on my nodejs-express-server app. This app is an openapi API server stub created from openapi-generator-cli.
Was referring to this post about excluding params while logging the request. My intention here is to detect authorization header ("api_token") in the request and mask its value. When I log request as is, without any filtering I see a massive log entry of about 1000+ lines after I JSON format it. I could use some pointers on

  1. Masking selected headers (Using express-winston or any other library)
  2. Reducing the request size on the log

Here's a filter I am trying out. Code follows.

    function maskTokenFilter(req, propName) {
      if(propName !== "headers" || propName !== "rawHeaders") {
        return req[propName];
      } 
      if(propName == "headers" ){
        const { api_token, ...rest } = req.headers;
        if(api_token) {
          return Object.assign({api_token: '*** masked ***'},rest);
        }   
      }
      if(propName == "rawHeaders" ){
        const { api_token, ...rest } = req.rawHeaders;
        if(api_token) {
          return Object.assign({api_token: '*** masked ***'},rest);
        }   
      }     
    }

The complete request entry on express-winston log is shared here. (Note: I JSON formatted it for readability)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!