framework.middleware('my-module-middleware', function(req, res, next, options) { next() });
framework.use('my-module-middleware');
framework.on('request', function(req, res) {});
framework.on('request-begin', function(req, res) {});
framework.on('controller', function(controller) {});
Scenario:
1. We have two users A & B on two different browsers
2. A make request on http://127.0.0.1:8000/set/1
Set -> 1
3. After that A make request http://127.0.0.1:8000/get/
Get -> 1
4. B make request on http://127.0.0.1:8000/get/
Get -> 1
So you can see value set by different user taken from module scope. Value is stored in the same memory space for single module.
Possible solution: always bind current request to module and get cookie data from it, make additional stuff and return value.
So in controllers/main.js do something like:
this.module('strange').bind(req).getValue();
or
this.module('strange').getValue(req);
The thing is, that the best case will be when in middleware we can get, parses and save somewhere cookie data per request and after that I can use this stored value in executed framework.module method in the same request thread.
Question is: how to store it during request thread? Is there any better option to not explicite pass request object?
I'm thinking around options like:
https://www.npmjs.org/package/continuation-local-storage
this.module('strange').getValue(req);