sessionstore
Advanced tools
Comparing version 1.2.18 to 1.3.0
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
module.exports = require('./lib/sessionstore'); |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
var util = require('util'), | ||
@@ -4,0 +2,0 @@ Session = require('../sessionInterface'), |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
var util = require('util'), | ||
@@ -4,0 +2,0 @@ Session = require('../sessionInterface'), |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
var util = require('util'), | ||
@@ -4,0 +2,0 @@ Session = require('../sessionInterface'), |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
var util = require('util'), | ||
@@ -4,0 +2,0 @@ Session = require('../sessionInterface'), |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
var util = require('util'), | ||
@@ -91,33 +89,56 @@ Session = require('../sessionInterface'), | ||
var client = new mongo.MongoClient(); | ||
var client; | ||
client.connect(connectionUrl, options.options, function(err, db) { | ||
if (err) { | ||
if (callback) callback(err); | ||
} else { | ||
if (mongo.MongoClient.length === 2) { | ||
client = new mongo.MongoClient(connectionUrl, options.options); | ||
client.connect(function(err, cl) { | ||
if (err) { | ||
debug(err); | ||
if (callback) callback(err); | ||
return; | ||
} | ||
self.db = cl.db(cl.s.options.dbName); | ||
if (!self.db.close) { | ||
self.db.close = cl.close.bind(cl); | ||
} | ||
initDb(); | ||
}); | ||
} else { | ||
client = new mongo.MongoClient(); | ||
client.connect(connectionUrl, options.options, function(err, db) { | ||
if (err) { | ||
debug(err); | ||
if (callback) callback(err); | ||
return; | ||
} | ||
self.db = db; | ||
initDb(); | ||
}); | ||
} | ||
self.db.on('close', function() { | ||
self.isConnected = false; | ||
self.emit('disconnect'); | ||
self.stopHeartbeat(); | ||
}); | ||
function initDb() { | ||
self.db.on('close', function() { | ||
self.isConnected = false; | ||
self.emit('disconnect'); | ||
self.stopHeartbeat(); | ||
}); | ||
var finish = function (err) { | ||
self.sessions = self.db.collection(options.collectionName); | ||
self.sessions.ensureIndex({ expires: 1 }, { expireAfterSeconds: 0 }, function() {}); | ||
if (!err) { | ||
self.isConnected = true; | ||
self.emit('connect'); | ||
var finish = function (err) { | ||
self.sessions = self.db.collection(options.collectionName); | ||
self.sessions.ensureIndex({ expires: 1 }, { expireAfterSeconds: 0 }, function() {}); | ||
if (!err) { | ||
self.isConnected = true; | ||
self.emit('connect'); | ||
if (self.options.heartbeat) { | ||
self.startHeartbeat(); | ||
} | ||
if (self.options.heartbeat) { | ||
self.startHeartbeat(); | ||
} | ||
if (callback) callback(err, self); | ||
}; | ||
} | ||
if (callback) callback(err, self); | ||
}; | ||
finish(); | ||
} | ||
}); | ||
finish(); | ||
} | ||
}, | ||
@@ -124,0 +145,0 @@ |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
var util = require('util'), | ||
@@ -4,0 +2,0 @@ Session = require('../sessionInterface'), |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
var util = require('util'), | ||
@@ -4,0 +2,0 @@ Session = require('../sessionInterface'), |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
var sessionInterface, | ||
@@ -4,0 +2,0 @@ expressPkg; |
@@ -1,6 +0,19 @@ | ||
'use strict'; | ||
var sessionInterface = require('../lib/sessionInterface'), | ||
tolerate = require('tolerance'); | ||
function exists(toCheck) { | ||
var _exists = require('fs').existsSync || require('path').existsSync; | ||
if (require('fs').accessSync) { | ||
_exists = function (toCheck) { | ||
try { | ||
require('fs').accessSync(toCheck); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
}; | ||
} | ||
return _exists(toCheck); | ||
} | ||
function getSpecificStore(options) { | ||
@@ -12,6 +25,5 @@ options = options || {}; | ||
options.type = options.type.toLowerCase(); | ||
var dbPath = __dirname + "/databases/" + options.type + ".js"; | ||
var exists = require('fs').existsSync || require('path').existsSync; | ||
if (!exists(dbPath)) { | ||
@@ -47,3 +59,3 @@ var errMsg = 'Implementation for db "' + options.type + '" does not exist!'; | ||
} | ||
options = options || {}; | ||
@@ -50,0 +62,0 @@ |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
var prequire = require('parent-require'); | ||
@@ -4,0 +2,0 @@ |
{ | ||
"author": "adrai", | ||
"name": "sessionstore", | ||
"version": "1.2.18", | ||
"version": "1.3.0", | ||
"private": false, | ||
@@ -14,5 +14,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"async": "1.5.2", | ||
"async": "2.6.0", | ||
"jsondate": "0.0.1", | ||
"lodash": "4.11.1", | ||
"lodash": "4.17.4", | ||
"parent-require": "1.0.0", | ||
@@ -28,5 +28,5 @@ "tolerance": "1.0.0" | ||
"express-session": ">= 1.0.0", | ||
"memjs": ">= 0.8.4", | ||
"mocha": ">= 1.0.1", | ||
"mongodb": ">= 1.x", | ||
"memjs": "0.x.x", | ||
"mocha": "3.x.x", | ||
"mongodb": "2.1.x", | ||
"redis": ">= 0.10.1", | ||
@@ -33,0 +33,0 @@ "tingodb": ">= 0.0.1" |
@@ -136,3 +136,3 @@ # Introduction | ||
## Catch connect ad disconnect events | ||
## Catch connect and disconnect events | ||
@@ -173,3 +173,3 @@ var ss = sessionstore.createSessionStore({ type: 'mongodb' }, function(err, ss) { | ||
Copyright (c) 2015 Adriano Raiano | ||
Copyright (c) 2018 Adriano Raiano | ||
@@ -176,0 +176,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
@@ -0,1 +1,4 @@ | ||
### [v1.3.0](https://github.com/adrai/sessionstore/compare/v1.2.18...v1.3.0) | ||
- compatibility with new mongodb version (3.x) | ||
### [v1.2.18](https://github.com/adrai/sessionstore/compare/v1.2.16...v1.2.18) | ||
@@ -2,0 +5,0 @@ - fix for new mongodb driver |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45144
1137
15
5
+ Addedasync@2.6.0(transitive)
+ Addedlodash@4.17.4(transitive)
- Removedasync@1.5.2(transitive)
- Removedlodash@4.11.1(transitive)
Updatedasync@2.6.0
Updatedlodash@4.17.4