Skip to content

Commit

Permalink
Express 4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
biggora committed Apr 20, 2014
1 parent 9128c6a commit efcf0df
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To install connect-caminte:

$ npm install -g connect-caminte

## Usage overview
## Usage overview (for Express 3)

```js
var express = require('express'),
Expand Down Expand Up @@ -72,6 +72,47 @@ app.get('/', function(req, res){
app.listen(3000);
```

## Usage overview (for Express 4)

```js
var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var CaminteStore = require('connect-caminte')(session);
var app = express();

app.use(cookieParser());
app.use(session({
cookie: {
maxAge: 60000 // 1 min as example
},
secret: "Wild CaminteJS",
store: new CaminteStore({
driver: 'sqlite3',
collection: 'mysession',
db: {
database: "./db/data.db"
},
maxAge: 300000, // 3 min
clear_interval: 60 // 1 min
})
}));

app.get('/', function(req, res){
var sess = req.session;
if (sess.views) {
res.send('<p>views: ' + sess.views + '</p>'
+ '<p>expires in: ' + (sess.cookie.maxAge / 1000) + 's</p>');
sess.views++;
} else {
sess.views = 1;
res.send('welcome to the session demo. refresh!');
}
});

app.listen(3000);
```

## Options
* `driver` Database driver name
* `collection` Store collection to host sessions. 'session' by default.
Expand Down
2 changes: 1 addition & 1 deletion lib/connect-caminte.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports.version = '0.0.2';
* @api public
*/
module.exports = function(connect) {
var Store = connect.session.Store;
var Store = connect.Store || connect.session.Store;

/**
* Initialize CaminteStore with the given `options`.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "connect-caminte",
"description": "CrossDB session store for Connect and ExpressJS",
"version": "0.0.2-1",
"version": "0.0.3",
"homepage": "https://github.com/biggora/connect-caminte/",
"repository": {
"type": "git",
Expand Down

0 comments on commit efcf0df

Please sign in to comment.