-
-
Save ipiyer/30934e4827b6d10fa627 to your computer and use it in GitHub Desktop.
Express + postgres + knex + bookshelf example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const session = require('express-session'), | |
pg = require("pg"), | |
pgSession = require('connect-pg-simple')(session); | |
const pgConnection = { | |
host: 'localhost', | |
user: 'blahblah', | |
database: 'foobar', | |
charset: 'utf8' | |
} | |
const knex = require('knex')({ | |
client: 'pg', | |
connection: pgConnection, | |
debug: true | |
}), | |
bookshelf = require('bookshelf')(knex); | |
// middleware | |
app.use(session({ | |
store: new pgSession({ | |
pg: pg, | |
conString: pgConnection, | |
tableName: 'session' | |
}), | |
resave: false, | |
saveUninitialized: true, | |
secret: "i am a secret", | |
cookie: { | |
maxAge: 1 * 365 * 24 * 60 * 60 * 1000 // 1 years; | |
} | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment