const express = require("express"); const app = express(); const mongoose = require("mongoose"); const url = "mongodb://devroot:devroot@localhost:27017/fsopen?authSource=admin"; mongoose.set("strictQuery", false); mongoose.connect(url); const noteSchema = new mongoose.Schema({ content: String, important: Boolean, }); noteSchema.set("toJSON", { transform: (document, returnedObject) => { returnedObject.id = returnedObject._id.toString(); delete returnedObject._id; delete returnedObject.__v; }, }); const Note = mongoose.model("Note", noteSchema); app.use(express.json()); let notes = [ { id: "1", content: "HTML is easy", important: true }, { id: "2", content: "Browser can execute only JavaScript", important: false }, { id: "3", content: "GET and POST are the most important methods of HTTP protocol", important: true, }, ]; const generateId = () => { const maxId = notes.length > 0 ? Math.max(...notes.map((n) => Number(n.id))) : 0; return String(maxId + 1); }; app.get("/", (request, response) => { response.send("