Created
January 12, 2015 23:41
-
-
Save joepie91/7a353dafa6305603dd40 to your computer and use it in GitHub Desktop.
Using a persistent object in Express
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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