better-sqlite3-sessions-store provides a better-sqlite3 session storage for express-session.
$ npm i --save better-sqlite3-session-store
const sqlite = require("better-sqlite3");
const session = require("express-session")
const SqliteStore = require("better-sqlite3-session-store")(session)
const db = new sqlite("sessions.db", { verbose: console.log });
app.use(
session({
store: new SqliteStore({
client: db,
expired: {
clear: true,
intervalMs: 900000 //ms = 15min
}
}),
secret: "keyboard cat",
resave: false,
saveUninitialized: false,
})
)
See License.
- Use correct temporal unit for express's
cookie.maxAge
(it's milliseconds) - Make calling
cb
function parameter safe- (breaking) Remove TypeScript support
- Add TypeScript support
- Add (optional)
all
method
- Bug fix: For almost all Store methods, when an error was caught, their
execution wasn't stopped with e.g. a
return
statement
- Release initial version
To build this library, I looked at other session stores: