better-sqlite3-session-store
Version:
A session store for express-session.
71 lines (48 loc) • 1.75 kB
Markdown
# better-sqlite3-session-store
[](https://badge.fury.io/js/better-sqlite3-session-store) [](https://github.com/TimDaub/better-sqlite3-session-store/workflows/Node.js%20CI/badge.svg)
> **better-sqlite3-sessions-store** provides a
> [better-sqlite3](https://github.com/JoshuaWise/better-sqlite3/) session
> storage for [express-session](https://github.com/expressjs/session).
## Install
```bash
$ npm i --save better-sqlite3-session-store
```
## Usage
```js
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,
})
)
```
## License
See [License](./LICENSE).
## Changelog
### 0.1.0
- Use correct temporal unit for express's `cookie.maxAge` (it's milliseconds)
- Make calling `cb` function parameter safe
- (breaking) Remove TypeScript support
### 0.0.3
- Add TypeScript support
- Add (optional) `all` method
### 0.0.2
- Bug fix: For almost all Store methods, when an error was caught, their
execution wasn't stopped with e.g. a `return` statement
### 0.0.1
- Release initial version
## Inspiration
To build this library, I looked at other session stores:
- [connect-sqlite3](https://github.com/rawberg/connect-sqlite3)
- [connect-redis](https://github.com/tj/connect-redis/)