const express = require("express");
const { MongoClient, ServerApiVersion, ObjectId } = require("mongodb");
const app = express();
const cors = require("cors");
const port = 5000;
const bcrypt = require("bcrypt");
const saltRounds = 10;

//Middleware
app.use(cors());
app.use(express.json());

const uri =
  "mongodb+srv://bike-store-backend:<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>/bikeStoreDB?retryWrites=true&w=majority&appName=Cluster0";
// Create a MongoClient with a MongoClientOptions object to set the Stable API version
const client = new MongoClient(uri, {
  serverApi: {
    version: ServerApiVersion.v1,
    strict: true,
    deprecationErrors: true,
  },
});
async function run() {
  try {
    // Connect the client to the server	(optional starting in v4.7)
    await client.connect();

    const userCollection = client.db().collection("user");
    const productCollection = client.db().collection("products");
    const orderCollection = client.db().collection("orders")

    // Authentication

    app.post("/signup", async (req, res) => {
      const { name, photo, email, password } = req.body;
      const hashedPassword = await bcrypt.hash(password, saltRounds);
      const newUser = {
        name,
        photo,
        email,
        password: hashedPassword,
      };
      const result = await userCollection.insertOne(newUser);
      res.send({
        data: result,
        status: 200,
        message: "user created successfully",
      });
    });

    app.post("/signin", async (req, res) => {
      const { email, password } = req.body;
      const user = await userCollection.findOne({ email: email });
      if (!user) {
        return res.status(404).send({ status: 404, message: "User not found" });
      }
      const isPasswordMatched = await bcrypt.compare(password, user.password);
      if (isPasswordMatched) {
        res.send({
          data: user,
          status: 200,
          message: "Logged in successfully",
        });
      } else {
        res.status(404).send({ status: 404, message: "Invalid Credential" });
      }
    });

    // Products section
    app.post("/create-product", async (req, res) => {
      const newProduct = req.body;

      const result = await productCollection.insertOne(newProduct);
      res.send({
        data: result,
        status: 200,
        message: "Product created successfully",
      });
    });

    app.get("/products", async (req, res) => {
      const result = await productCollection.find().toArray();
      res.send({
        data: result,
        status: 200,
        message: "Retrieve all products successfully",
      });
    });

    app.get("/products/:id", async (req, res) => {
      const { id } = req.params;
      const result = await productCollection.findOne({ _id: new ObjectId(id) });
      res.send({
        data: result,
        status: 200,
        message: "Product retrieve successfully",
      });
    });

    app.delete("/products/:id", async (req, res) => {
      const { id } = req.params;

      const result = await productCollection.deleteOne({
        _id: new ObjectId(id),
      });
      res.send({
        data: result,
        status: 200,
        message: "Product deleted successfully",
      });
    });

    app.put("/products/:id", async (req, res) => {
      const { id } = req.params;
      const filter = {_id: new ObjectId(id)}
      const updatedProduct = req.body;
      const updateDocument = {
        $set: {
          title: updatedProduct.title,
          img: updatedProduct.img,
          description: updatedProduct.description,
          price: updatedProduct.price,
          rating: updatedProduct.rating,
          category: updatedProduct.category,
          featured: updatedProduct.featured,
        },
      };
      const result = await productCollection.updateOne( filter, updateDocument);
      res.send({
        data: result,
        status: 200,
        message: "Product update successfully",
      });
    });

    // order section

    app.post("/order", async (req, res) => {
      const newOrder = req.body;
      const result = await orderCollection.insertOne(newOrder);
      res.send({
        data: result,
        status: 200,
        message: "Order created successfully",
      });
    });

    app.get("/cart-list", async(req, res) => {
      const {email} = req.body
      const result = await orderCollection.find({email: email}).toArray()
      res.send({
        data: result,
        status: 200,
        message: "Order retrieve successfully",
      });

    })

    // Send a ping to confirm a successful connection
    await client.db("admin").command({ ping: 1 });
    console.log(
      "Pinged your deployment. You successfully connected to MongoDB!"
    );
  } finally {
    // Ensures that the client will close when you finish/error
    // await client.close();
  }
}
run().catch(console.dir);

app.get("/", (req, res) => {
  res.send("Hello World!");
});

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`);
});
_____________

I m using only mongodb and express to build this server .
Can you make me this in mvc format as well as use mongose for this