A MySQL store for membership.js
Add to your application via npm
:
npm install membership-mysql-store --save
This will install membership-mysql-store
and add it to your application's package.json
file.
Use with your express session middleware, like this:
var MysqlMembershipStore = require("membership-mysql-store");
var options = {
host: 'localhost',
port: 3306,
user: 'session_test',
password: 'password',
database: 'session_test',
syncDB: false
};
var mysqlMembershipStore = new MysqlMembershipStore(options);
mysqlMembershipStore.createUser({
email: "mail@example.com"
}, "hashedpassword").then(function(user){
console.log(user);
}).catch(function(error){
console.error(error);
});
express-mysql-session
uses the debug module to output debug messages to the console. To output all debug messages, run your node app with the DEBUG
environment variable:
DEBUG=express-mysql-session* node your-app.js
This will output log messages as well as error messages from express-mysql-session
.
If you also might need MySQL-related debug and error messages, include mysql-connection-manager
as well:
DEBUG=express-mysql-session*,mysql-connection-manager node your-app.js
First, you'll need to pull down the code from GitHub:
git clone https://github.com/ErezAlster/membership-mysql-store.git
Second, you'll need to install the project dependencies as well as the dev dependencies. To do this, simply run the following from the directory you created in step 1:
npm install
Now, you'll need to set up a local test database:
{
host: 'localhost',
port: 3306,
user: 'session_test',
password: 'password',
database: 'session_test',
syncDB: true
}
The test database settings are located in test/config.json
With your local environment configured, running tests is as simple as:
npm test