express-mongodb-middleware
v1.0.8
Published
Simple way to pass a mongodb instance to all of your express routes
Downloads
34
Readme
express-mongodb-middleware
npm install express-mongodb-middleware
Example
import express from "express";
import mongodb from "mongodb";
import expressMongo from "express-mongodb-middleware";
const app = express();
const db = new mongodb.MongoClient();
app.use(expressMongo(db));
app.get("/", (req, res) => {
const database = req.db;
// Use the connected MongoClient here.
});
app.listen(3000, () => console.log("Listening!"));