rhapsodyjs / RhapsodyJS

NodeJS HMVC framework for epic apps.
http://rhapsodyjs.github.io/
MIT License
65 stars 5 forks source link

Custom session-store setup #15

Open riston opened 9 years ago

riston commented 9 years ago

Hello, I just started working with your framework. But there seems to be problems with setting up the custom session stores, have you tried the connect-mongo or connect-redis ? Could you also provide some examples, how the store config should be ?

In the config/session.js you option for passing the session store but, like in connect-mongo you need to have also the instance of session.

var session    = require('express-session');
var MongoStore = require('connect-mongo')(session);

app.use(session({
    secret: settings.cookie_secret,
    store: new MongoStore({
      db : settings.db,
    })
  }));

Currently the store option is passed forward but its never called:

            this.config.session.sessionStore = this.config.session.sessionStore || new this.middlewares.session.MemoryStore();

            //Actives session support
            this.app.use(this.middlewares.session({
                secret: this.config.session.sessionSecret,
                name: sessionIDKey,
                cookie: {
                    httpOnly: true,
                    maxAge: maxAge
                },
                store: this.config.session.sessionStore,
...
            }));
talyssonoc commented 9 years ago

I guess I forgot that, sorry =( Gonna fix it soon, thanks!

Edit: Now I see why I forgot that, in my tests I used this: https://www.npmjs.com/package/connect-mongodb