A MongoDB session store for @fastify/session. By default @fastify/session uses in-memory storage to store sessions. With this small package you can store sessions on an MongoDB database instead.
npm i --save @voidpkg/fastify-mongo-store
# or
yarn add @voidpkg/fastify-mongo-store
Use with @fastify/session
's store
property.
import { Store } from "@voidpkg/fastify-mongo-store";
import fastify from "fastify";
const app = fastify();
app.register(require("@fastify/cookie"));
app.register(require("@fastify/session"), {
secret: "a secret with minimum length of 32 characters",
store: new Store({
collection: "sessions",
url: "mongodb://127.0.0.1:27017",
database: "fastify-mongodb-store"
})
});
© 2019 — 2023 Void Development, Ltd. All rights reserved.