Closed dom19191 closed 7 years ago
What's the problem this fixes?
Go over all the internal properties of the object and they are not necessary in this scoop. Else this kind of configuration doesn't work... the previous modification do the job.
var website = require('./db_website.js');
var session_store = {};
module.exports = {
load: function (app)
{
var express_session = require('express-session');
var express_mysql_session = require('express-mysql-session');
var express_session_store = express_mysql_session(express_session);
var db_website_session_config = {
host: website.get('app_db_host'),
port: 3306,
user: website.get('app_db_user'),
password: website.get('app_db_password'),
database: website.get('app_db_database'),
schema: {
tableName: 'sessions',
columnNames: {
session_id: 'session_id',
expires: 'expires',
data: 'data'
}},
checkExpirationInterval: 900000,// How frequently expired sessions will be cleared; milliseconds.
expiration: 86400000,// The maximum age of a valid session; milliseconds.
connectionLimit: 1// Number of connections when creating a connection pool
};
session_store = new express_session_store(db_website_session_config);
app.use(express_session({
key: '55555-55555-55555',
secret: '66666-66666-66666',
store: session_store,
resave: false,
saveUninitialized: false,
cookie: { secure: true }
}));
return true;
}
}
Maybe the solution is to use the _.defaults function from the underscore utility library. Fewer things to break/test in this module is better.
I won't have time for a while. So pull requests are welcome :)
I've added underscore to replace several methods used internally. An instance of express-mysql-session will now have its default options set using the _.defaults
method with the schema
option being the only one set recursively.
I found a correction... for the next release!