jurisv / nodejs.extdirect

Ext.Direct connector for node.js (npm module)
41 stars 16 forks source link

Add access to req object #12

Closed jurisv closed 10 years ago

srguiwiz commented 10 years ago

Related to jurisv/extdirect.examples#11

Did an experiment with express.session.MemoryStore, and its req.session object contains an id property (req.session.id) with its own ID and even with req (circular reference req.session.req). Not sure about other stores, but think if someone would need the session ID they could put it into their session if it weren't there.

Therefore I suggest changing route.js code to

        if(req.session){
            so.data.push(req.session);
        }

instead of with req.sessionID.

Admittedly, that would need an incompatible upgrade warning and a new version number, 1.3.0. I think it is better to make such change early in the life of a (this) library. Tough choice, but I also think people will "get it", either they will see in the debugger what is different, or they will see the upgrade warning.

But it would solve the cookieSession problem, which don't have an ID, and which are nice for minimal sessions (almost stateless) because they don't need elaborate server side mechanisms.

Memory use? The req already exists for the length of time of request processing, and it already has a reference to the session object, so there wouldn't be any new allocation.

srguiwiz commented 10 years ago

Of couse req gives access to more, and then how about res?

Today I only need session.

To be bold and ask for it all (req and res), or to exercise restraint and only ask for session?

Today I only need session. Still true 20 seconds later.

jurisv commented 10 years ago

This was my original intention, (add extra objects in full), you are writing faster here as I can respond and implement :)

jurisv commented 10 years ago

Version 1.3.1