The problem that I am trying to solve is maintaining information about a user across a connection. In a request there are various commands which get independently processed one by one. In one command the user can supply credentials and get a token back, and then in subsequent requests they can supply this token to authenticate themselves. But I don't want them to have to supply the token multiple times in a single request: I want a function to know that the token has already been supplied and use it. However, there are other modules in use which don't know anything about the current request connection, they simply accept a token and other arguments and do their work.
In this related questions, Is it possible to declare global variables in Node/Express 4.0, it appears to ask about global variables, not specified to the current connection. Global Variable in app.js accessible in routes? seems to ask a similar question. However obviously this is not appropriate if there are multiple users, because credentials for each user need to apply onto to and for the duration of their connection.
How can I create a "global" variable that modules that don't know anything about the current connection can look at to determine information about the current connection only?