New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-mongoose-store

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-mongoose-store - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

24

index.js

@@ -143,18 +143,14 @@ module.exports = function(session, mongoose){

MongooseStore.prototype.keepAlive = function(){
debug('KEEPALIVE Querying Mongoose for empty set.');
Session.find({ noexits: true }, function(err, data){
if(err){
debug('KEEPALIVE error, %s', err);
} else {
debug('KEEPALIVE success');
}
});
}
return MongooseStore;
}
/*
Session.find({})
.exec(function(err, data){
if(err){
debug('The following error occurred in find(): %s', err)
}
if(data.length){
debug('Found the following records in find(): %s', data)
} else {
debug('Found no records in find(): %s', data)
}
})
*/
{
"name": "express-mongoose-store",
"version": "1.0.0",
"version": "1.0.1",
"description": "Session store for people who want to use MongoDB sessions, and already have a MongooseJS connection for their backend.",

@@ -5,0 +5,0 @@ "main": "./index.js",

@@ -21,7 +21,30 @@ ##Express Mongoose Store

var mongoose = require('mongoose');
mongoose.connect();
var MS = require('express-mongoose-store')(session, mongoose);
app.use(session({ secret: 'keyboard cat', store: new MS({ttl: 600000}) }); //10 minute sessions
````
Or if you want the session store to keep your Mongoose connection alive as well you can do the following:
````
var session = require('express-session');
var mongoose = require('mongoose');
mongoose.connect();
var MS = require('express-mongoose-store')(session, mongoose);
var mongoose_store = new MS();
setInterval(function(){
mongoose_store.keepAlive();
}, 20000);
app.use(session({ secret: 'keyboard cat', store: mongoose_store });
````
Essentially if your server has a lull in activity this protects your mongoose connection from timing out and having to reconnect, which in express can cause you to throw an error to a user.
###Test

@@ -34,2 +57,2 @@ Running tests requires a MongoDB instance running on 127.0.0.1:27017 with no authentication. It will also

npm test
````
````

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc