Registry / database / bedrock-session-mongodb

bedrock-session-mongodb

JSON →
library4.3.1jsnpmunverified

A bedrock module that enables express session storage via MongoDB. It integrates with the bedrock framework to persist session data in MongoDB, supporting Express.js session middleware. The current stable version 4.3.1 requires peer dependencies bedrock ^4.5.0, bedrock-express ^6.4.1, and bedrock-mongodb ^8.5.0. Compared to alternatives like connect-mongo, this module is tightly coupled to the bedrock ecosystem and follows bedrock's configuration patterns.

npm install bedrock-session-mongodb
INSTALL
IMPORT
SIG · BEDROCK-SESSION-MO
B
bedrock-session-mongodb
databasejavascriptv4.3.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
require('bedrock-session-mongodb')
import bedrockSessionMongodb from 'bedrock-session-mongodb'
This module is CommonJS only; it must be required for side effects (registers itself with bedrock). ESM import is not supported.
bedrock
const bedrock = require('bedrock')
import bedrock from 'bedrock'
Bedrock modules are CommonJS; use require for both bedrock and this module.
bedrock.events.on
bedrock.events.on('bedrock-express.configure.routes', callback)
bedrock.on('bedrock-express.configure.routes', callback)
Event listener is on bedrock.events, not bedrock directly.

Quickstart showing how to require the module to enable MongoDB session storage with bedrock and Express.

const bedrock = require('bedrock'); require('bedrock-server'); require('bedrock-express'); require('bedrock-session-mongodb'); bedrock.events.on('bedrock-express.configure.routes', function(app) { app.get('/', function(req, res) { res.send('Hello World!'); }); }); bedrock.start();
Debug
Known issues
breakingRequires bedrock v4.5 or later and bedrock-mongodb v8.5.
fix
Upgrade bedrock to ^4.5.0 and bedrock-mongodb to ^8.5.0
affects: <4.3.0
deprecatedThe require pattern may change in future versions to support ESM.
fix
Monitor migration guide when upgrading major versions.
affects: >=4.3.0
gotchaMust require bedrock-server and bedrock-express before bedrock-session-mongodb.
fix
Ensure require order: bedrock, bedrock-server, bedrock-express, then this module.
affects: >=4.0.0
gotchaConfiguration is loaded from bedrock config; does not work standalone.
fix
Use bedrock configuration system to set MongoDB connection options.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'bedrock-session-mongodb'
Missing npm install or incorrect module name.
fix
Run 'npm install bedrock-session-mongodb'
Error: Cannot find module 'bedrock'
Missing peer dependency bedrock.
fix
Run 'npm install bedrock@^4.5.0'
TypeError: bedrock.events.on is not a function
bedrock module not properly required or version mismatch.
fix
Ensure bedrock is required and version ^4.5.0.
Upgrade
Version history
4.3.1latest on npm
Audit
Dependencies
bedrockrequiredCore framework peer dependency
bedrock-expressrequiredExpress integration peer dependency
bedrock-mongodbrequiredMongoDB driver peer dependency
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
bedrock-session-mongodb — npm install bedrock-session-mongodb · libregistry