Skip to content
This repository was archived by the owner on Jun 15, 2022. It is now read-only.

Latest commit

 

History

History
31 lines (19 loc) · 933 Bytes

File metadata and controls

31 lines (19 loc) · 933 Bytes

express-mongodb-middleware

npm GitHub license GitHub stars

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