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

connect-session-knex

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-session-knex - npm Package Compare versions

Comparing version 1.0.6 to 1.0.8

.travis.yml

33

History.md

@@ -1,22 +0,20 @@

0.0.1 / 2014-07-09
1.0.7 (2014-12-13)
==================
* Forked from connect-sqlite3
* PostgreSQL bugfixes. Now building on Travis CI.
0.0.2
1.0.6 (2014-12-13)
==================
* Optimized PostgreSQL query
* MySQL/Mariadb support
1.0.0
1.0.5 (2014-12-8)
==================
* Updated Readme and benchmarks.
* Optimized SQLite3 query
1.0.2
1.0.4
==================
* Bugfixes
* Bugfixes

@@ -29,3 +27,3 @@

1.0.4
1.0.2
==================

@@ -35,12 +33,17 @@ * Bugfixes

1.0.5
1.0.0
==================
* Optimized SQLite3 query
* Updated Readme and benchmarks.
1.0.6
0.0.2
==================
* MySQL/Mariadb support
* Optimized PostgreSQL query
0.0.1 (2014-07-09)
==================
* Forked from connect-sqlite3

@@ -105,3 +105,3 @@ 'use strict';

var sess = response[0].sess;
if (typeof(sess) === "string") {
if (typeof sess === "string") {
sess = JSON.parse(sess);

@@ -116,2 +116,3 @@ }

fn(err);
throw err;
});

@@ -161,3 +162,3 @@ });

return that.ready.then(function () {
return that.knex.raw(sqlitefastq, [sid, new Date(expired).toJSON(), sess ])
return that.knex.raw(sqlitefastq, [sid, new Date(expired).toISOString(), sess ])
.then(function (result) {

@@ -167,2 +168,6 @@ if (fn && result instanceof Array) {

}
})
.catch(function (err) {
fn(err);
throw err;
});

@@ -173,3 +178,3 @@ });

return that.ready.then(function () {
return that.knex.raw(postgresfastq, [sid, new Date(expired), sess ])
return that.knex.raw(postgresfastq, [sid, new Date(expired).toISOString(), sess ])
.then(function (result) {

@@ -179,2 +184,6 @@ if (fn) {

}
})
.catch(function (err) {
fn(err);
throw err;
});

@@ -185,3 +194,3 @@ });

return that.ready.then(function () {
return that.knex.raw(mysqlfastq, [sid, new Date(expired), sess ])
return that.knex.raw(mysqlfastq, [sid, new Date(expired).toISOString(), sess ])
.then(function (result) {

@@ -191,2 +200,6 @@ if (fn) {

}
})
.catch(function (err) {
fn(err);
throw err;
});

@@ -203,3 +216,3 @@ });

sid: sid,
expired: new Date(expired),
expired: new Date(expired).toISOString(),
sess: sess

@@ -211,3 +224,3 @@ });

.update({
expired: new Date(expired),
expired: new Date(expired).toISOString(),
sess: sess

@@ -226,2 +239,3 @@ });

fn(err);
throw err;
});

@@ -246,2 +260,6 @@ });

}
})
.catch(function(err) {
fn(err);
throw err;
});

@@ -263,4 +281,8 @@ });

if (fn) {
fn(null, response[0].count);
fn(null, response[0].count | 0);
}
})
.catch(function(err) {
fn(err);
throw err;
});

@@ -284,2 +306,6 @@ });

}
})
.catch(function(err) {
fn(err);
throw err;
});

@@ -286,0 +312,0 @@ });

{
"name": "connect-session-knex",
"description": "Knex.js session store for Connect",
"version": "1.0.6",
"description": "A knex.js session store for Express and Connect",
"version": "1.0.8",
"main": "lib/connect-session-knex",
"dependencies": {
"knex": "^0.7.3"
},
"engines": {
"node": ">=0.4.x"
"node": ">=0.10.x"
},

@@ -21,3 +18,3 @@ "repository": {

"scripts": {
"test": "cd spec && mocha"
"test": "cd spec && ../node_modules/mocha/bin/mocha"
},

@@ -28,2 +25,6 @@ "license": "ISC",

"express-session": "^1.9.3",
"knex": "^0.7.3",
"mocha": "^2.0.1",
"mysql": "^2.5.3",
"pg": "^4.1.1",
"should": "^4.3.0",

@@ -30,0 +31,0 @@ "sqlite3": "^3.0.4"

# Connect Session Knex
[![Build Status](https://travis-ci.org/llambda/connect-session-knex.svg?branch=master)](https://travis-ci.org/llambda/connect-session-knex)
connect-session-knex is a session store using [knex.js](http://knexjs.org/), which is a SQL query builder for Postgres, MySQL, MariaDB and SQLite3.

@@ -13,3 +15,3 @@

With express 4.x:
With express 4.x and the default sqlite3 DB:

@@ -28,2 +30,29 @@ ```js

With express 4.x and PostgreSQL:
```js
var session = require('express-session');
var KnexSessionStore = require('connect-session-knex')(session);
var knexPg = require('knex')({
client: 'pg',
connection: {
host: '127.0.0.1',
user: 'postgres',
password: '',
database: 'travis_ci_test'
}
});
var store = new KnexSessionStore({
knex: knexPg,
tablename: 'sessions'
});
app.use(session({
store: store,
secret: 'your secret',
cookie: { maxAge: 7 * 24 * 60 * 60 * 1000 } // 1 week
}));
```
With express 3.x:

@@ -30,0 +59,0 @@

@@ -8,83 +8,268 @@ 'use strict';

var sqliteStore = new KnexStore({db: ':memory:', dir: 'dbs'});
describe('connect-sqlite3 basic test suite', function() {
before(function() {
this.store = new KnexStore({db: ':memory:', dir: 'dbs'});
});
var knexPg = require('knex')({
client: 'pg',
connection: {
host: '127.0.0.1',
user: 'postgres',
password: '',
database: 'travis_ci_test'
}
});
after(function() {
// this.store.close();
});
var knexMysql = require('knex')({
client: 'mysql',
connection: {
host: '127.0.0.1',
user: 'travis',
password: '',
database: 'travis_ci_test'
}
});
it('it should save a new session record', function(done) {
this.store.set('1111222233334444', {cookie: {maxAge: 20000}, name: 'sample name'}, function(err, rows) {
should.not.exist(err, 'set() returned an error');
rows.should.eql([1]);
done();
});
});
var postgresStore = new KnexStore({ knex: knexPg });
var mysqlStore = new KnexStore({ knex: knexMysql });
it('it should retrieve an active session', function(done) {
this.store.get('1111222233334444', function(err, session) {
should.not.exist(err, 'get() returned an error');
should.exist(session);
(session).should.eql({cookie: {maxAge: 20000 }, name: 'sample name'});
done();
});
});
it('it should gracefully handle retrieving an unkonwn session', function(done) {
this.store.get('hope-and-change', function(err, rows) {
should.not.exist(err, 'get() unknown session returned an error');
should.equal(undefined, rows, 'unknown session is not undefined');
done();
});
});
describe('connect-session-knex sqlite3 test suite', function() {
before(function() {
// this.store = new KnexStore({db: ':memory:', dir: 'dbs'});
this.store = sqliteStore;
});
it('it should only contain one session', function(done) {
this.store.length(function(err, len) {
should.not.exist(err, 'session count returned an error');
should.exist(len);
len.should.equal(1);
done();
});
});
after(function() {
// this.store.close();
});
it('it should clear all session records', function(done) {
var that = this;
this.store.clear(function(err, success) {
should.not.exist(err, 'clear returned an error');
success.should.be.true;
it('it should save a new session record', function(done) {
this.store.set('1111222233334444', {cookie: {maxAge: 20000}, name: 'sample name'}, function(err, rows) {
should.not.exist(err, 'set() returned an error');
rows.should.eql([1]);
done();
});
});
that.store.length(function(err, len) {
should.not.exist(err, 'session count after clear returned an error');
should.exist(len);
len.should.equal(0);
done();
});
});
});
it('it should destroy a session', function(done) {
var that = this;
this.store.set('555666777', {cookie: {maxAge: 1000}, name: 'Rob Dobilina'}, function(err, rows) {
should.not.exist(err, 'set() returned an error');
rows.should.eql([1]);
it('it should retrieve an active session', function(done) {
this.store.get('1111222233334444', function(err, session) {
should.not.exist(err, 'get() returned an error');
should.exist(session);
(session).should.eql({cookie: {maxAge: 20000 }, name: 'sample name'});
done();
});
});
that.store.destroy('555666777', function(err) {
should.not.exist(err, 'destroy returned an error');
it('it should gracefully handle retrieving an unkonwn session', function(done) {
this.store.get('hope-and-change', function(err, rows) {
should.not.exist(err, 'get() unknown session returned an error');
should.equal(undefined, rows, 'unknown session is not undefined');
done();
});
});
that.store.length(function(err, len) {
should.not.exist(err, 'session count after destroy returned an error');
should.exist(len);
len.should.equal(0);
done();
});
});
});
});
it('it should only contain one session', function(done) {
this.store.length(function(err, len) {
should.not.exist(err, 'session count returned an error');
should.exist(len);
len.should.equal(1);
done();
});
});
it('it should clear all session records', function(done) {
var that = this;
this.store.clear(function(err, success) {
should.not.exist(err, 'clear returned an error');
success.should.be.true;
that.store.length(function(err, len) {
should.not.exist(err, 'session count after clear returned an error');
should.exist(len);
len.should.equal(0);
done();
});
});
});
it('it should destroy a session', function(done) {
var that = this;
this.store.set('555666777', {cookie: {maxAge: 1000}, name: 'Rob Dobilina'}, function(err, rows) {
should.not.exist(err, 'set() returned an error');
rows.should.eql([1]);
that.store.destroy('555666777', function(err) {
should.not.exist(err, 'destroy returned an error');
that.store.length(function(err, len) {
should.not.exist(err, 'session count after destroy returned an error');
should.exist(len);
len.should.equal(0);
done();
});
});
});
});
});
describe('connect-session-knex postgreSQL test suite', function() {
before(function() {
this.store = postgresStore;
});
after(function() {
// this.store.close();
});
it('it should save a new session record', function(done) {
this.store.set('1111222233334444', {cookie: {maxAge: 20000}, name: 'sample name'}, function(err, rows) {
should.not.exist(err, 'set() returned an error');
rows.rowCount.should.eql(1);
done();
});
});
it('it should retrieve an active session', function(done) {
this.store.get('1111222233334444', function(err, session) {
should.not.exist(err, 'get() returned an error');
should.exist(session);
(session).should.eql({cookie: {maxAge: 20000 }, name: 'sample name'});
done();
});
});
it('it should gracefully handle retrieving an unkonwn session', function(done) {
this.store.get('hope-and-change', function(err, rows) {
should.not.exist(err, 'get() unknown session returned an error');
should.equal(undefined, rows, 'unknown session is not undefined');
done();
});
});
it('it should only contain one session', function(done) {
this.store.length(function(err, len) {
should.not.exist(err, 'session count returned an error');
should.exist(len);
len.should.equal(1);
done();
});
});
it('it should clear all session records', function(done) {
var that = this;
this.store.clear(function(err, success) {
should.not.exist(err, 'clear returned an error');
success.should.be.true;
that.store.length(function(err, len) {
should.not.exist(err, 'session count after clear returned an error');
should.exist(len);
len.should.equal(0);
done();
});
});
});
it('it should destroy a session', function(done) {
var that = this;
this.store.set('555666777', {cookie: {maxAge: 1000}, name: 'Rob Dobilina'}, function(err, rows) {
should.not.exist(err, 'set() returned an error');
rows.rowCount.should.eql(1);
that.store.destroy('555666777', function(err) {
should.not.exist(err, 'destroy returned an error');
that.store.length(function(err, len) {
should.not.exist(err, 'session count after destroy returned an error');
should.exist(len);
len.should.equal(0);
done();
});
});
});
});
});
describe('connect-session-knex MySQL test suite', function() {
before(function() {
this.store = mysqlStore;
});
after(function() {
// this.store.close();
});
it('it should save a new session record', function(done) {
this.store.set('1111222233334444', {cookie: {maxAge: 20000}, name: 'sample name'}, function(err, rows) {
should.not.exist(err, err);
rows[0].affectedRows.should.eql(1);
done();
});
});
it('it should retrieve an active session', function(done) {
this.store.get('1111222233334444', function(err, session) {
should.not.exist(err, 'get() returned an error');
should.exist(session);
(session).should.eql({cookie: {maxAge: 20000 }, name: 'sample name'});
done();
});
});
it('it should gracefully handle retrieving an unkonwn session', function(done) {
this.store.get('hope-and-change', function(err, rows) {
should.not.exist(err, 'get() unknown session returned an error');
should.equal(undefined, rows, 'unknown session is not undefined');
done();
});
});
it('it should only contain one session', function(done) {
this.store.length(function(err, len) {
should.not.exist(err, 'session count returned an error');
should.exist(len);
len.should.equal(1);
done();
});
});
it('it should clear all session records', function(done) {
var that = this;
this.store.clear(function(err, success) {
should.not.exist(err, 'clear returned an error');
success.should.be.true;
that.store.length(function(err, len) {
should.not.exist(err, 'session count after clear returned an error');
should.exist(len);
len.should.equal(0);
done();
});
});
});
it('it should destroy a session', function(done) {
var that = this;
this.store.set('555666777', {cookie: {maxAge: 1000}, name: 'Rob Dobilina'}, function(err, rows) {
should.not.exist(err, 'set() returned an error');
rows[0].affectedRows.should.eql(1);
that.store.destroy('555666777', function(err) {
should.not.exist(err, 'destroy returned an error');
that.store.length(function(err, len) {
should.not.exist(err, 'session count after destroy returned an error');
should.exist(len);
len.should.equal(0);
done();
});
});
});
});
});
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