Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

connect-lowdb

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-lowdb - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

90

lib/connect-lowdb.js

@@ -15,51 +15,59 @@ const lowdbStore = (session) => {

async get(sid, cb) {
await this.db.read();
get(sid, cb) {
this.db.read()
.then(() => {
this.db.data ||= { sessions: [] };
this.db.data.sessions ||= [];
this.db.data.sessions ||= [];
const dbSession = this.db.data.sessions
.find(session => session.sid === sid);
const dbSession = this.db.data.sessions
.find(session => session.sid === sid);
cb(null, dbSession ? dbSession.session : null);
cb(null, dbSession ? dbSession.session : null);
})
.catch((err) => { cb(err); });;
}
async set(sid, session, cb) {
await this.db.read();
this.db.data.sessions ||= [];
const sessionObj = {
sid,
session,
};
const dbSession = this.db.data.sessions
.find(session => session.sid === sid);
if (dbSession) {
const dbSessionIx = this.db.data.sessions
.findIndex(session => session.sid === sid);
this.db.data.sessions[dbSessionIx] = sessionObj;
} else {
this.db.data.sessions.push(sessionObj);
}
await this.db.write();
cb(null);
set(sid, session, cb) {
this.db.read()
.then(() => {
this.db.data ||= { sessions: [] };
this.db.data.sessions ||= [];
const sessionObj = { sid, session };
const dbSession = this.db.data.sessions
.find(session => session.sid === sid);
if (dbSession) {
const dbSessionIx = this.db.data.sessions
.findIndex(session => session.sid === sid);
this.db.data.sessions[dbSessionIx] = sessionObj;
} else {
this.db.data.sessions.push(sessionObj);
}
this.db.write()
.then(() => { cb(null); })
.catch((err) => { cb(err); });;
})
.catch((err) => { cb(err); });;
}
async destroy(sid, cb) {
await this.db.read();
destroy(sid, cb) {
this.db.read()
.then(() => {
this.db.data ||= { sessions: [] };
this.db.data.sessions ||= [];
this.db.data.sessions ||= [];
const dbSessionIx = this.db.data.sessions
.findIndex(session => session.sid === sid);
const dbSessionIx = this.db.data.sessions
.findIndex(session => session.sid === sid);
this.db.data.sessions.splice(dbSessionIx, 1);
await this.db.write();
cb(null);
this.db.data.sessions.splice(dbSessionIx, 1);
this.db.write()
.then(() => { cb(null); })
.catch((err) => { cb(err); });
})
.catch((err) => { cb(err); });;
}

@@ -66,0 +74,0 @@ }

{
"name": "connect-lowdb",
"version": "1.0.0",
"version": "1.0.1",
"description": "lowdb session store for Connect",

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

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