Skip to content

VoidDevsorg/fastify-mongo-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@voidpkg/fastify-mongo-store

node version License: MIT

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"
    })
});


© 2019 — 2023 Void Development, Ltd. All rights reserved.

Releases

No releases published

Packages

No packages published