In express ...
app usually the name of the variable in which the application object returned by express() is storedreq usually the name of a function parameter that processes a particular type of request
The key difference is, obviously, the lifetime of the corresponding objects: the one stored in req is saved until a specific request is serviced (after that the handler function ends, taking all local parameters - and arguments - with it), the one that is stored in the app , works as long as the application is running.
On the bottom line, the data stored in app.locals is saved between requests.
raina77ow
source share