Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda