-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V2.1.3 - Addresses various issues (#33)
Version bump; v2.1.3 - Addresses various issues
- Loading branch information
Showing
5 changed files
with
485 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Contributing to connect-mysql | ||
|
||
## Code Contributions | ||
|
||
This document will guide you through the contribution process. | ||
|
||
### Step 1: Fork | ||
|
||
Fork the project [on GitHub](https://github.com/nlf/connect-mysql) and check out your | ||
copy locally. | ||
|
||
```text | ||
$ git clone [email protected]:username/connect-mysql.git | ||
$ cd node | ||
$ git remote add upstream git://github.com/nlf/connect-mysql.git | ||
``` | ||
|
||
Keep your local fork update to date using the `upstream` branch indicated in | ||
the above commands. | ||
|
||
#### Which branch? | ||
|
||
For developing new features and bug fixes, the `master` branch should be pulled | ||
and built upon. | ||
|
||
### Step 2: Branch | ||
|
||
Create a feature branch and start hacking: | ||
|
||
```text | ||
$ git checkout -b my-feature-branch -t origin/master | ||
``` | ||
|
||
The branch name should be descriptive about the fixes/features it will | ||
address. | ||
|
||
### Step 3: Commit | ||
|
||
Make sure git knows your name and email address: | ||
|
||
```text | ||
$ git config --global user.name "J. Random User" | ||
$ git config --global user.email "[email protected]" | ||
``` | ||
|
||
Writing good commit logs is important. A commit log should describe what | ||
changed and why. Follow these guidelines when writing one: | ||
|
||
1. The first line should be 50 characters or less and contain a short | ||
description of the change prefixed with the name of the changed | ||
subsystem (e.g. "net: add localAddress and localPort to Socket"). | ||
2. Keep the second line blank. | ||
3. Wrap all other lines at 72 columns. | ||
|
||
A good commit log can look something like this: | ||
|
||
``` | ||
subsystem: explaining the commit in one line | ||
Body of commit message is a few lines of text, explaining things | ||
in more detail, possibly giving some background about the issue | ||
being fixed, etc. etc. | ||
The body of the commit message can be several paragraphs, and | ||
please do proper word-wrap and keep columns shorter than about | ||
72 characters or so. That way `git log` will show things | ||
nicely even when it is indented. | ||
``` | ||
|
||
The header line should be meaningful; it is what other people see when they | ||
run `git shortlog` or `git log --oneline`. | ||
|
||
Check the output of `git log --oneline files_that_you_changed` to find out | ||
what subsystem (or subsystems) your changes touch. | ||
|
||
|
||
### Step 4: Rebase | ||
|
||
Use `git rebase` (not `git merge`) to sync your work from time to time (as | ||
mentioned in 'Step 1'). | ||
|
||
```text | ||
$ git fetch upstream | ||
$ git rebase upstream/master | ||
``` | ||
|
||
### Step 5: Test | ||
|
||
Bug fixes and features **should come with tests**. Add your tests in the | ||
test directory. Look at other tests to see how they should be | ||
structured. | ||
|
||
```text | ||
$ npm test | ||
``` | ||
|
||
### Step 6: Push | ||
|
||
```text | ||
$ git push origin my-feature-branch | ||
``` | ||
|
||
Go to https://github.com/yourusername/connect-mysql and select your feature | ||
branch. Click the 'Pull Request' button and fill out the form. | ||
|
||
Pull requests are usually reviewed within a few days. If there are comments | ||
to address, apply your changes in a separate commit and push that to your | ||
feature branch. Post a comment in the pull request afterwards; GitHub does | ||
not send out notifications when you add commits. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Programmed by Nathan LaFreniere, Copyright (c) 2012 &Yet | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,96 @@ | ||
#connect-mysql | ||
# connect-mysql | ||
|
||
This is a simple MySQL backed session store for connect. | ||
|
||
It uses the [node-mysql](https://github.com/felixge/node-mysql) module already installed in your project to establish and pool connections. | ||
|
||
## Options | ||
|
||
* `table`: the name of the database table that should be used for storing sessions. Defaults to `'sessions'` | ||
* `pool`: a node-mysql connection pool or `true` if the store should instantiate its own pool | ||
* `config`: the configuration that will be passed to `createConnection()` or `createPool()` if pool is `true` | ||
* `retries`: how many times to retry connecting to the database before failing. Defaults to `3` | ||
* `keepalive`: keep pooled connections open by periodically pinging them. Set to `true` to use the default interval of `30000` ms or provide a positive number to set your own. Defaults to `true`. | ||
* `cleanup`: a boolean specifying whether to enable the cleanup events. note that if this is disabled, cleanup will not take place at all and should be done externally. Sessions with an expiration time of `0` will always be ignored and should also be cleaned up externally. | ||
* `secret`: key that will be used to encrypt session data. If this option is not provided then data will be stored in plain text | ||
* `algorithm`: the algorithm that should be used to encrypt session data. Defaults to `'aes-256-ctr'` | ||
|
||
## Usage | ||
|
||
## Examples | ||
Here are some example use cases to get your application up and running. | ||
|
||
### Default use case | ||
Simple use case using the `express` framework & `connect-session` middleware with `connect-mysql` as the data store. | ||
|
||
```javascript | ||
var express = require('express'), | ||
MySQLStore = require('connect-mysql')(express), | ||
options = { | ||
config: { | ||
user: 'dbuser', | ||
password: 'dbpassword', | ||
database: 'db' | ||
} | ||
session = require('connect-session'), | ||
MySQLStore = require('connect-mysql')(session), | ||
options = { | ||
config: { | ||
user: 'dbuser', | ||
password: 'dbpassword', | ||
database: 'db' | ||
} | ||
}; | ||
|
||
var app = express.createServer(); | ||
|
||
app.use(express.cookieParser()); | ||
app.use(express.session({ secret: 'supersecretkeygoeshere', store: new MySQLStore(options))); | ||
app.use(express.session({ | ||
secret: 'supersecretkeygoeshere', | ||
store: new MySQLStore(options)) | ||
}); | ||
``` | ||
For connection pooling use | ||
### Connection pooling example | ||
For those MySQL installations that make use of pools the following examples are available. | ||
```javascript | ||
... | ||
mysql = reqire('mysql'), | ||
options = { | ||
pool: mysql.createPool({ user: 'dbuser', password: 'dbpassword', database: 'db' }) | ||
}; | ||
... | ||
var mysql = require('mysql'), | ||
options = { | ||
pool: mysql.createPool({ | ||
user: 'dbuser', | ||
password: 'dbpassword', | ||
database: 'db' | ||
}) | ||
}; | ||
``` | ||
Or | ||
```javascript | ||
... | ||
options = { | ||
pool: true, | ||
config: { | ||
user: 'dbuser', | ||
password: 'dbpassword', | ||
database: 'db' | ||
} | ||
}; | ||
... | ||
var options = { | ||
pool: true, | ||
config: { | ||
user: 'dbuser', | ||
password: 'dbpassword', | ||
database: 'db' | ||
} | ||
}; | ||
``` | ||
To use session encryption: | ||
### Ssession encryption example | ||
This option enables transparent session encryption assisting | ||
```javascript | ||
... | ||
options = { | ||
secret: 'thesessionsecret', | ||
config: { | ||
user: 'dbuser', | ||
password: 'dbpassword', | ||
database: 'db' | ||
} | ||
}; | ||
... | ||
var options = { | ||
secret: 'thesessionsecret', | ||
config: { | ||
user: 'dbuser', | ||
password: 'dbpassword', | ||
database: 'db' | ||
} | ||
}; | ||
``` | ||
## Options | ||
* `table`: the name of the database table that should be used for storing sessions. Defaults to `'sessions'` | ||
* `pool`: a node-mysql connection pool or `true` if the store should instantiate its own pool | ||
* `config`: the configuration that will be passed to `createConnection()` or `createPool()` if pool is `true` | ||
* `retries`: how many times to retry connecting to the database before failing. Defaults to `3` | ||
* `keepalive`: keep pooled connections open by periodically pinging them. Set to `true` to use the default interval of `30000` ms or provide a positive number to set your own. Defaults to `true`. | ||
* `cleanup`: a boolean specifying whether to enable the cleanup events. note that if this is disabled, cleanup will not take place at all and should be done externally. Sessions with an expiration time of `0` will always be ignored and should also be cleaned up externally. | ||
* `secret`: key that will be used to encrypt session data. If this option is not provided then data will be stored in plain text | ||
* `algorithm`: the algorithm that should be used to encrypt session data. Defaults to `'aes-256-ctr'` | ||
## contributing ## | ||
Contributions are welcome & appreciated. Refer to the [contributing document](https://github.com/nlf/connect-mysql/blob/master/CONTRIBUTING.md) | ||
to help facilitate pull requests. | ||
## license ## | ||
This software is licensed under the [MIT License](https://github.com/nlf/connect-mysql/blob/master/LICENSE). | ||
----- | ||
License: MIT | ||
Nathan LaFreniere, Copyright (c) 2012 &Yet |
Oops, something went wrong.