Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ app.set("port", port);
* Set up mongoose connection
*/
const mongoose = require("mongoose");
mongoose.set("strictQuery", false);
const dev_db_url =
"mongodb+srv://cooluser:coolpassword@cluster0.cojoign.mongodb.net/local_library?retryWrites=true&w=majority&appName=Cluster0";
const mongoDB = process.env.MONGODB_URI || dev_db_url;
Expand All @@ -33,6 +32,15 @@ try {

async function connectMongoose() {
await mongoose.connect(mongoDB);

// Add connection error handlers
mongoose.connection.on('error', err => {
console.error('MongoDB connection error:', err);
});

mongoose.connection.on('disconnected', () => {
console.warn('MongoDB disconnected');
});
}

/**
Expand Down
117 changes: 97 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"helmet": "^8.1.0",
"http-errors": "^2.0.0",
"luxon": "^3.6.1",
"mongoose": "^8.16.2",
"mongoose": "^9.2.1",
"morgan": "^1.10.0",
"pug": "^3.0.3"
},
Expand Down
3 changes: 1 addition & 2 deletions populatedb.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const books = [];
const bookinstances = [];

const mongoose = require("mongoose");
mongoose.set("strictQuery", false);

const mongoDB = userArgs[0];

Expand All @@ -33,7 +32,7 @@ async function main() {
await createBooks();
await createBookInstances();
console.log("Debug: Closing mongoose");
mongoose.connection.close();
await mongoose.connection.close();
}

// We pass the index to the ...Create functions so that, for example,
Expand Down
1 change: 0 additions & 1 deletion test/utils/test_db.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ let mongoServer;
async function connect() {
mongoServer = await MongoMemoryServer.create();
const uri = mongoServer.getUri();
mongoose.set("strictQuery", false);
await mongoose.connect(uri);
}

Expand Down