@voidpkg/fastify-mongo-store
v1.0.1
Published
A fastify session store using MongoDB
Downloads
2
Readme
@voidpkg/fastify-mongo-store
Introduction
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.
Installation
npm i --save @voidpkg/fastify-mongo-store
# or
yarn add @voidpkg/fastify-mongo-store
Usage
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"
})
});