Skip to content

Instantly share code, notes, and snippets.

@joepie91
Created January 12, 2015 23:41
Show Gist options
  • Save joepie91/7a353dafa6305603dd40 to your computer and use it in GitHub Desktop.
Save joepie91/7a353dafa6305603dd40 to your computer and use it in GitHub Desktop.
Using a persistent object in Express
someObject = instantiateSomePersistentObjectSomehow();
app.use(function(req, res, next) {
req.someObject = someObject;
next();
});
// ...
app.get("/sample/route", function(req, res) {
console.log("We still have our persistent object...", req.someObject);
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment