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

209
Vistas
Is there a way in NodeJS to create global variables that live only for the lifetime of the request?

I'm creating an API using Express, and I wanna know if there is a way to create a global variable (something like a global store) that only keeps data for the duration of the request.

I understand that because NodeJS handles all requests in the same thread, any global variable I create will persist across requests. So I wonder if there's a clean way to achieve what I want to.

Does NodeJS or Express provide a way where I could clean up this global state at the end of each request? Like an event or something similar. Or is there a package that already does this?

Maybe I could get way leveraging closures, but I'm looking for something more flexible.

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