Skip to content

Instantly share code, notes, and snippets.

@antishok
Last active September 10, 2016 13:52
Show Gist options
  • Save antishok/fb3d003d16eb72f672a7cc36401657d9 to your computer and use it in GitHub Desktop.
Save antishok/fb3d003d16eb72f672a7cc36401657d9 to your computer and use it in GitHub Desktop.
connect-session-knex issue
Listening on port 3000
express:router dispatching GET /increment +6s
express:router query : /increment +3ms
express:router expressInit : /increment +1ms
express:router session : /increment +2ms
express-session fetching 9uxMmBYUXEWSBRlZH2f8j0X3IH4eYFyb +5ms
express-session session found +8ms
express-session saving 9uxMmBYUXEWSBRlZH2f8j0X3IH4eYFyb +8ms
express-session split response +1ms
express:router dispatching GET / +9ms
express:router query : / +0ms
express:router expressInit : / +1ms
express:router session : / +0ms
express-session fetching 9uxMmBYUXEWSBRlZH2f8j0X3IH4eYFyb +1ms
express-session session found +5ms
express-session touching +2ms
express-session touched +1ms
express-session ENTERED WRITEEND. req.originalUrl: / +0ms
express-session ENTERED WRITEEND. req.originalUrl: /increment +8ms
Listening on port 3000
express:router dispatching GET /increment +2s
express:router query : /increment +3ms
express:router expressInit : /increment +1ms
express:router session : /increment +1ms
express-session fetching vsz9hN50DwNfmmp8e_vzOOqrZ3pV-U8L +2ms
express-session session found +7ms
express-session saving vsz9hN50DwNfmmp8e_vzOOqrZ3pV-U8L +7ms
express-session split response +1ms
express-session ENTERED WRITEEND. req.originalUrl: /increment +22ms
express:router dispatching GET / +180ms
express:router query : / +1ms
express:router expressInit : / +1ms
express:router session : / +1ms
express-session fetching vsz9hN50DwNfmmp8e_vzOOqrZ3pV-U8L +1ms
express-session session found +9ms
express-session touching +5ms
express-session touched +0ms
express-session ENTERED WRITEEND. req.originalUrl: / +1ms
{
"name": "test",
"version": "0.1.0",
"main": "test.js",
"dependencies": {
"express": "^4.14.0",
"express-session": "^1.14.1",
"knex": "^0.11.10",
"connect-session-knex": "^1.0.23",
"pg": "^6.1.0"
}
}
var express = require('express');
var session = require('express-session');
var KnexSessionStore = require('connect-session-knex')(session);
var knex = require('knex')({
client: 'pg',
connection: {
database: 'postgres',
user: 'postgres',
password: 'ppp'
}
});
var app = express();
app.use(session({
store: new KnexSessionStore({knex: knex}),
secret: 'secrets',
saveUninitialized: false,
resave: false
}));
app.get('/', (req, res) => {
res.send('counter: ' + req.session.bla + '<br/><a href="/increment">increment counter</a>')
});
app.get('/increment', (req, res) => {
req.session.bla = 1 + (req.session.bla || 0);
res.redirect('/');
});
app.listen(3000, () => {
console.log('Listening on port 3000');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment