1var router = require("express").Router()
2
3var varSetMiddleware = function(res,req,next){
4 router.variable = 100
5 // set the variable inside the router object
6 // now you can access it anywhere in this specific router
7 next()
8}
9
10router.get("/first_view", function (req, res) {
11 // something
12 console.log(router.variable) //100
13 res.send("something")
14})
15
16router.get('/second_view', function (req, res) {
17 // something
18 console.log(router.variable) //100
19 res.send("something")
20
21module.exports = router