Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/voiddevsorg/fastify-mongo-store
A fastify session store using MongoDB
https://github.com/voiddevsorg/fastify-mongo-store
Last synced: 20 days ago
JSON representation
A fastify session store using MongoDB
- Host: GitHub
- URL: https://github.com/voiddevsorg/fastify-mongo-store
- Owner: VoidDevsorg
- License: mit
- Created: 2023-07-30T07:32:05.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-30T07:43:38.000Z (over 1 year ago)
- Last Synced: 2023-07-30T08:26:33.287Z (over 1 year ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@voidpkg/fastify-mongo-store
- Size: 0 Bytes
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @voidpkg/fastify-mongo-store
![node version](https://img.shields.io/badge/node%20-%3E=%2018.x-brightgreen.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)## Introduction
A [MongoDB](https://github.com/mongodb/node-mongodb-native) session store for [@fastify/session](https://github.com/fastify/session). By default [@fastify/session](https://github.com/fastify/session) uses in-memory storage to store sessions. With this small package you can store sessions on an **MongoDB** database instead.
## Installation
```bash
npm i --save @voidpkg/fastify-mongo-store
# or
yarn add @voidpkg/fastify-mongo-store
```## Usage
Use with `@fastify/session`'s `store` property.
```ts
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"
})
});
```---