From b8aaadd9cd090979b161fe0bcf4e1e12f2deab48 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Wed, 9 Sep 2026 16:21:38 -0700 Subject: [PATCH 1/4] Sync finished code with modernized guide --- .gitignore | 41 +- app.js | 64 +- bin/www | 115 -- controllers/authorController.js | 27 +- controllers/bookController.js | 40 +- controllers/bookinstanceController.js | 27 +- controllers/genreController.js | 29 +- models/author.js | 49 +- models/book.js | 15 +- models/bookinstance.js | 24 +- models/genre.js | 8 +- package-lock.json | 1211 +++++++---------- package.json | 38 +- populatedb.js | 43 +- .../Library Website - Mongoose_Express.png | Bin 17146 -> 0 bytes routes/catalog.js | 86 +- routes/index.js | 10 +- routes/users.js | 9 +- server.js | 34 + views/author_delete.pug | 2 +- views/author_detail.pug | 4 +- views/author_form.pug | 6 +- views/author_list.pug | 1 - views/book_delete.pug | 2 +- views/book_list.pug | 3 +- views/bookinstance_delete.pug | 2 +- views/bookinstance_detail.pug | 2 +- views/bookinstance_form.pug | 2 +- views/genre_delete.pug | 2 +- views/genre_detail.pug | 4 +- views/genre_form.pug | 2 +- views/genre_list.pug | 9 +- views/index.pug | 2 +- 33 files changed, 812 insertions(+), 1101 deletions(-) delete mode 100644 bin/www delete mode 100644 public/images/Library Website - Mongoose_Express.png create mode 100644 server.js diff --git a/.gitignore b/.gitignore index c60a7e52..53a89d1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,40 +1,3 @@ -# Logs -logs +node_modules/ *.log -npm-debug.log* -*.bak - - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules -jspm_packages - -# Optional npm cache directory -.npm - -# Optional REPL history -.node_repl_history - +.env diff --git a/app.js b/app.js index 7e4c3155..5ffab3a2 100644 --- a/app.js +++ b/app.js @@ -1,66 +1,66 @@ -const createError = require("http-errors"); -const express = require("express"); -const path = require("path"); -const cookieParser = require("cookie-parser"); -const logger = require("morgan"); -const RateLimit = require("express-rate-limit"); +import path from "node:path"; +import createError from "http-errors"; +import express from "express"; +import logger from "morgan"; +import compression from "compression"; +import helmet from "helmet"; +import RateLimit from "express-rate-limit"; -const indexRouter = require("./routes/index"); -const usersRouter = require("./routes/users"); -const catalogRouter = require("./routes/catalog"); // Import routes for "catalog" area of site - -const compression = require("compression"); -const helmet = require("helmet"); +import indexRouter from "./routes/index.js"; +import usersRouter from "./routes/users.js"; +import catalogRouter from "./routes/catalog.js"; // Import routes for "catalog" area of site const app = express(); // Set up rate limiter: maximum of twenty requests per minute const limiter = RateLimit({ - windowMs: 1 * 60 * 1000, // 10 seconds - max: 60, + windowMs: 1 * 60 * 1000, // 1 minute + max: 20, }); // Apply rate limiter to all requests app.use(limiter); -// view engine setup -app.set("views", path.join(__dirname, "views")); -app.set("view engine", "pug"); - -app.use(logger("dev")); -app.use(express.json()); -app.use(express.urlencoded({ extended: false })); -app.use(cookieParser()); - +// Add helmet to the middleware chain. +// Set CSP headers to allow our Bootstrap scripts to be served app.use( helmet.contentSecurityPolicy({ directives: { "script-src": ["'self'", "cdn.jsdelivr.net"], }, - }) + }), ); +// view engine setup +app.set("views", path.join(import.meta.dirname, "views")); +app.set("view engine", "pug"); + +app.use(logger("dev")); +app.use(express.json()); +app.use(express.urlencoded({ extended: false })); app.use(compression()); // Compress all routes -app.use(express.static(path.join(__dirname, "public"))); +app.use(express.static(path.join(import.meta.dirname, "public"))); app.use("/", indexRouter); app.use("/users", usersRouter); app.use("/catalog", catalogRouter); // Add catalog routes to middleware chain. // catch 404 and forward to error handler -app.use(function (req, res, next) { +app.use((req, res, next) => { next(createError(404)); }); // error handler -app.use(function (err, req, res, next) { - // set locals, only providing error in development +app.use((err, req, res, next) => { + if (res.headersSent) { + next(err); + return; + } + res.locals.message = err.message; res.locals.error = req.app.get("env") === "development" ? err : {}; - - // render the error page - res.status(err.status || 500); + res.status(err.status ?? 500); res.render("error"); }); -module.exports = app; +export default app; diff --git a/bin/www b/bin/www deleted file mode 100644 index 52142660..00000000 --- a/bin/www +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env node - -/** - * Module dependencies. - */ - -var app = require("../app"); -var debug = require("debug")("express-locallibrary-tutorial:server"); -var http = require("http"); - -/** - * Get port from environment and store in Express. - */ - -let port = normalizePort(process.env.PORT || "3000"); -app.set("port", port); - -/** - * Set up mongoose connection - */ -const mongoose = require("mongoose"); -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; - -connectMongoose() - .then(startServer) - .catch((err) => { - console.error("Failed to connect to MongoDB:", err); - process.exit(1); - }); - -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"); - }); -} - -/** - * Create HTTP server and listen on provided port, on all network - * interfaces, once the MongoDB connection is established. - */ - -var server; - -function startServer() { - server = http.createServer(app); - - server.listen(port); - server.on("error", onError); - server.on("listening", onListening); -} - -/** - * Event listener for HTTP server "error" event. - */ - -function onError(error) { - if (error.syscall !== "listen") { - throw error; - } - - var bind = typeof port === "string" ? "Pipe " + port : "Port " + port; - - // handle specific listen errors with friendly messages - switch (error.code) { - case "EACCES": - console.error(bind + " requires elevated privileges"); - process.exit(1); - break; - case "EADDRINUSE": - console.error(bind + " is already in use"); - process.exit(1); - break; - default: - throw error; - } -} - -/** - * Event listener for HTTP server "listening" event. - */ - -function onListening() { - var addr = server.address(); - var bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port; - debug("Listening on " + bind); -} - -/** - * Normalize a port into a number, string, or false. - */ - -function normalizePort(val) { - var port = parseInt(val, 10); - - if (isNaN(port)) { - // named pipe - return val; - } - - if (port >= 0) { - // port number - return port; - } - - return false; -} diff --git a/controllers/authorController.js b/controllers/authorController.js index 09ffeb46..225c4eb4 100644 --- a/controllers/authorController.js +++ b/controllers/authorController.js @@ -1,10 +1,13 @@ -const Author = require("../models/author"); -const Book = require("../models/book"); +import createDebug from "debug"; +import { body, validationResult } from "express-validator"; -const { body, validationResult } = require("express-validator"); +import Author from "../models/author.js"; +import Book from "../models/book.js"; + +const debug = createDebug("author"); // Display list of all Authors. -exports.author_list = async (req, res, next) => { +export const authorList = async (req, res, next) => { const allAuthors = await Author.find().sort({ family_name: 1 }).exec(); res.render("author_list", { title: "Author List", @@ -13,7 +16,7 @@ exports.author_list = async (req, res, next) => { }; // Display detail page for a specific Author. -exports.author_detail = async (req, res, next) => { +export const authorDetail = async (req, res, next) => { // Get details of author and all their books (in parallel) const [author, allBooksByAuthor] = await Promise.all([ Author.findById(req.params.id).exec(), @@ -35,12 +38,12 @@ exports.author_detail = async (req, res, next) => { }; // Display Author create form on GET. -exports.author_create_get = (req, res, next) => { +export const authorCreateGet = (req, res, next) => { res.render("author_form", { title: "Create Author" }); }; // Handle Author create on POST. -exports.author_create_post = [ +export const authorCreatePost = [ // Validate and sanitize fields. body("first_name") .trim() @@ -96,7 +99,7 @@ exports.author_create_post = [ ]; // Display Author delete form on GET. -exports.author_delete_get = async (req, res, next) => { +export const authorDeleteGet = async (req, res, next) => { // Get details of author and all their books (in parallel) const [author, allBooksByAuthor] = await Promise.all([ Author.findById(req.params.id).exec(), @@ -117,7 +120,7 @@ exports.author_delete_get = async (req, res, next) => { }; // Handle Author delete on POST. -exports.author_delete_post = async (req, res, next) => { +export const authorDeletePost = async (req, res, next) => { // Get details of author and all their books (in parallel) const [author, allBooksByAuthor] = await Promise.all([ Author.findById(req.params.id).exec(), @@ -133,17 +136,17 @@ exports.author_delete_post = async (req, res, next) => { }); return; } - // Author has no books. Delete object and redirect to the list of authors. await Author.findByIdAndDelete(req.body.authorid); res.redirect("/catalog/authors"); }; // Display Author update form on GET. -exports.author_update_get = async (req, res, next) => { +export const authorUpdateGet = async (req, res, next) => { const author = await Author.findById(req.params.id).exec(); if (author === null) { // No results. + debug(`id not found on update: ${req.params.id}`); const err = new Error("Author not found"); err.status = 404; return next(err); @@ -153,7 +156,7 @@ exports.author_update_get = async (req, res, next) => { }; // Handle Author update on POST. -exports.author_update_post = [ +export const authorUpdatePost = [ // Validate and sanitize fields. body("first_name") .trim() diff --git a/controllers/bookController.js b/controllers/bookController.js index befd2350..06da786d 100644 --- a/controllers/bookController.js +++ b/controllers/bookController.js @@ -1,11 +1,11 @@ -const Book = require("../models/book"); -const Author = require("../models/author"); -const Genre = require("../models/genre"); -const BookInstance = require("../models/bookinstance"); +import { body, validationResult } from "express-validator"; -const { body, validationResult } = require("express-validator"); +import Book from "../models/book.js"; +import Author from "../models/author.js"; +import Genre from "../models/genre.js"; +import BookInstance from "../models/bookinstance.js"; -exports.index = async (req, res, next) => { +export const index = async (req, res, next) => { // Get details of books, book instances, authors and genre counts (in parallel) const [ numBooks, @@ -32,7 +32,7 @@ exports.index = async (req, res, next) => { }; // Display list of all books. -exports.book_list = async (req, res, next) => { +export const bookList = async (req, res, next) => { const allBooks = await Book.find({}, "title author") .sort({ title: 1 }) .populate("author") @@ -42,7 +42,7 @@ exports.book_list = async (req, res, next) => { }; // Display detail page for a specific book. -exports.book_detail = async (req, res, next) => { +export const bookDetail = async (req, res, next) => { // Get details of books, book instances for specific book const [book, bookInstances] = await Promise.all([ Book.findById(req.params.id).populate("author").populate("genre").exec(), @@ -64,7 +64,7 @@ exports.book_detail = async (req, res, next) => { }; // Display book create form on GET. -exports.book_create_get = async (req, res, next) => { +export const bookCreateGet = async (req, res, next) => { // Get all authors and genres, which we can use for adding to our book. const [allAuthors, allGenres] = await Promise.all([ Author.find().sort({ family_name: 1 }).exec(), @@ -79,7 +79,7 @@ exports.book_create_get = async (req, res, next) => { }; // Handle book create on POST. -exports.book_create_post = [ +export const bookCreatePost = [ // Convert the genre to an array. (req, res, next) => { if (!Array.isArray(req.body.genre)) { @@ -130,7 +130,7 @@ exports.book_create_post = [ // Mark our selected genres as checked. for (const genre of allGenres) { - if (book.genre.indexOf(genre._id) > -1) { + if (book.genre.includes(genre._id)) { genre.checked = "true"; } } @@ -151,7 +151,7 @@ exports.book_create_post = [ ]; // Display book delete form on GET. -exports.book_delete_get = async (req, res, next) => { +export const bookDeleteGet = async (req, res, next) => { const [book, bookInstances] = await Promise.all([ Book.findById(req.params.id).populate("author").populate("genre").exec(), BookInstance.find({ book: req.params.id }).exec(), @@ -160,6 +160,7 @@ exports.book_delete_get = async (req, res, next) => { if (book === null) { // No results. res.redirect("/catalog/books"); + return; } res.render("book_delete", { @@ -170,7 +171,7 @@ exports.book_delete_get = async (req, res, next) => { }; // Handle book delete on POST. -exports.book_delete_post = async (req, res, next) => { +export const bookDeletePost = async (req, res, next) => { // Assume the post has valid id (ie no validation/sanitization). const [book, bookInstances] = await Promise.all([ @@ -181,6 +182,7 @@ exports.book_delete_post = async (req, res, next) => { if (book === null) { // No results. res.redirect("/catalog/books"); + return; } if (bookInstances.length > 0) { @@ -194,12 +196,12 @@ exports.book_delete_post = async (req, res, next) => { } // Book has no BookInstance objects. Delete object and redirect to the list of books. - await Book.findByIdAndDelete(req.body.id); + await Book.findByIdAndDelete(req.params.id); res.redirect("/catalog/books"); }; // Display book update form on GET. -exports.book_update_get = async (req, res, next) => { +export const bookUpdateGet = async (req, res, next) => { // Get book, authors and genres for form. const [book, allAuthors, allGenres] = await Promise.all([ Book.findById(req.params.id).populate("author").exec(), @@ -228,7 +230,7 @@ exports.book_update_get = async (req, res, next) => { }; // Handle book update on POST. -exports.book_update_post = [ +export const bookUpdatePost = [ // Convert the genre to an array. (req, res, next) => { if (!Array.isArray(req.body.genre)) { @@ -280,7 +282,7 @@ exports.book_update_post = [ // Mark our selected genres as checked. for (const genre of allGenres) { - if (book.genre.includes(genre._id)) { + if (book.genre.indexOf(genre._id) > -1) { genre.checked = "true"; } } @@ -295,8 +297,8 @@ exports.book_update_post = [ } // Data from form is valid. Update the record. - const thebook = await Book.findByIdAndUpdate(req.params.id, book, {}); + const updatedBook = await Book.findByIdAndUpdate(req.params.id, book, {}); // Redirect to book detail page. - res.redirect(thebook.url); + res.redirect(updatedBook.url); }, ]; diff --git a/controllers/bookinstanceController.js b/controllers/bookinstanceController.js index 612733f0..fdab9835 100644 --- a/controllers/bookinstanceController.js +++ b/controllers/bookinstanceController.js @@ -1,10 +1,10 @@ -const BookInstance = require("../models/bookinstance"); -const Book = require("../models/book"); +import { body, validationResult } from "express-validator"; -const { body, validationResult } = require("express-validator"); +import BookInstance from "../models/bookinstance.js"; +import Book from "../models/book.js"; // Display list of all BookInstances. -exports.bookinstance_list = async (req, res, next) => { +export const bookInstanceList = async (req, res, next) => { const allBookInstances = await BookInstance.find().populate("book").exec(); res.render("bookinstance_list", { @@ -14,7 +14,7 @@ exports.bookinstance_list = async (req, res, next) => { }; // Display detail page for a specific BookInstance. -exports.bookinstance_detail = async (req, res, next) => { +export const bookInstanceDetail = async (req, res, next) => { const bookInstance = await BookInstance.findById(req.params.id) .populate("book") .exec(); @@ -33,7 +33,7 @@ exports.bookinstance_detail = async (req, res, next) => { }; // Display BookInstance create form on GET. -exports.bookinstance_create_get = async (req, res, next) => { +export const bookInstanceCreateGet = async (req, res, next) => { const allBooks = await Book.find({}, "title").sort({ title: 1 }).exec(); res.render("bookinstance_form", { @@ -43,7 +43,7 @@ exports.bookinstance_create_get = async (req, res, next) => { }; // Handle BookInstance create on POST. -exports.bookinstance_create_post = [ +export const bookInstanceCreatePost = [ // Validate and sanitize fields. body("book", "Book must be specified").trim().isLength({ min: 1 }).escape(), body("imprint", "Imprint must be specified") @@ -91,7 +91,7 @@ exports.bookinstance_create_post = [ ]; // Display BookInstance delete form on GET. -exports.bookinstance_delete_get = async (req, res, next) => { +export const bookInstanceDeleteGet = async (req, res, next) => { const bookInstance = await BookInstance.findById(req.params.id) .populate("book") .exec(); @@ -99,6 +99,7 @@ exports.bookinstance_delete_get = async (req, res, next) => { if (bookInstance === null) { // No results. res.redirect("/catalog/bookinstances"); + return; } res.render("bookinstance_delete", { @@ -108,14 +109,14 @@ exports.bookinstance_delete_get = async (req, res, next) => { }; // Handle BookInstance delete on POST. -exports.bookinstance_delete_post = async (req, res, next) => { +export const bookInstanceDeletePost = async (req, res, next) => { // Assume valid BookInstance id in field. - await BookInstance.findByIdAndDelete(req.body.id); + await BookInstance.findByIdAndDelete(req.params.id); res.redirect("/catalog/bookinstances"); }; // Display BookInstance update form on GET. -exports.bookinstance_update_get = async (req, res, next) => { +export const bookInstanceUpdateGet = async (req, res, next) => { // Get book, all books for form (in parallel) const [bookInstance, allBooks] = await Promise.all([ BookInstance.findById(req.params.id).populate("book").exec(), @@ -137,8 +138,8 @@ exports.bookinstance_update_get = async (req, res, next) => { }); }; -// Handle BookInstance update on POST. -exports.bookinstance_update_post = [ +// Handle bookinstance update on POST. +export const bookInstanceUpdatePost = [ // Validate and sanitize fields. body("book", "Book must be specified").trim().isLength({ min: 1 }).escape(), body("imprint", "Imprint must be specified") diff --git a/controllers/genreController.js b/controllers/genreController.js index 06d3a1fa..b9e8db39 100644 --- a/controllers/genreController.js +++ b/controllers/genreController.js @@ -1,19 +1,19 @@ -const Genre = require("../models/genre"); -const Book = require("../models/book"); +import { body, validationResult } from "express-validator"; -const { body, validationResult } = require("express-validator"); +import Genre from "../models/genre.js"; +import Book from "../models/book.js"; // Display list of all Genre. -exports.genre_list = async (req, res, next) => { +export const genreList = async (req, res, next) => { const allGenres = await Genre.find().sort({ name: 1 }).exec(); res.render("genre_list", { title: "Genre List", - list_genres: allGenres, + genre_list: allGenres, }); }; // Display detail page for a specific Genre. -exports.genre_detail = async (req, res, next) => { +export const genreDetail = async (req, res, next) => { // Get details of genre and all associated books (in parallel) const [genre, booksInGenre] = await Promise.all([ Genre.findById(req.params.id).exec(), @@ -34,12 +34,12 @@ exports.genre_detail = async (req, res, next) => { }; // Display Genre create form on GET. -exports.genre_create_get = (req, res, next) => { +export const genreCreateGet = (req, res, next) => { res.render("genre_form", { title: "Create Genre" }); }; // Handle Genre create on POST. -exports.genre_create_post = [ +export const genreCreatePost = [ // Validate and sanitize the name field. body("name", "Genre name must contain at least 3 characters") .trim() @@ -65,7 +65,7 @@ exports.genre_create_post = [ } // Data from form is valid. - // Check if Genre with same name (case insensitive) already exists. + // Check if Genre with same name already exists. const genreExists = await Genre.findOne({ name: req.body.name }) .collation({ locale: "en", strength: 2 }) .exec(); @@ -82,7 +82,7 @@ exports.genre_create_post = [ ]; // Display Genre delete form on GET. -exports.genre_delete_get = async (req, res, next) => { +export const genreDeleteGet = async (req, res, next) => { // Get details of genre and all associated books (in parallel) const [genre, booksInGenre] = await Promise.all([ Genre.findById(req.params.id).exec(), @@ -91,6 +91,7 @@ exports.genre_delete_get = async (req, res, next) => { if (genre === null) { // No results. res.redirect("/catalog/genres"); + return; } res.render("genre_delete", { @@ -101,7 +102,7 @@ exports.genre_delete_get = async (req, res, next) => { }; // Handle Genre delete on POST. -exports.genre_delete_post = async (req, res, next) => { +export const genreDeletePost = async (req, res, next) => { // Get details of genre and all associated books (in parallel) const [genre, booksInGenre] = await Promise.all([ Genre.findById(req.params.id).exec(), @@ -119,12 +120,12 @@ exports.genre_delete_post = async (req, res, next) => { } // Genre has no books. Delete object and redirect to the list of genres. - await Genre.findByIdAndDelete(req.body.id); + await Genre.findByIdAndDelete(req.params.id); res.redirect("/catalog/genres"); }; // Display Genre update form on GET. -exports.genre_update_get = async (req, res, next) => { +export const genreUpdateGet = async (req, res, next) => { const genre = await Genre.findById(req.params.id).exec(); if (genre === null) { @@ -138,7 +139,7 @@ exports.genre_update_get = async (req, res, next) => { }; // Handle Genre update on POST. -exports.genre_update_post = [ +export const genreUpdatePost = [ // Validate and sanitize the name field. body("name", "Genre name must contain at least 3 characters") .trim() diff --git a/models/author.js b/models/author.js index 17695006..61a669e6 100644 --- a/models/author.js +++ b/models/author.js @@ -1,5 +1,4 @@ -const mongoose = require("mongoose"); -const { DateTime } = require("luxon"); // for date handling +import mongoose from "mongoose"; const Schema = mongoose.Schema; @@ -10,39 +9,43 @@ const AuthorSchema = new Schema({ date_of_death: { type: Date }, }); -// Virtual for author "full" name. +// Virtual for author's full name AuthorSchema.virtual("name").get(function () { - return this.family_name + ", " + this.first_name; + // To avoid errors in cases where an author does not have either a family name or first name + // We want to make sure we handle the exception by returning an empty string for that case + let fullname = ""; + if (this.first_name && this.family_name) { + fullname = `${this.family_name}, ${this.first_name}`; + } + + return fullname; }); -// Virtual for this author instance URL. +// Virtual for author's URL AuthorSchema.virtual("url").get(function () { - return "/catalog/author/" + this._id; + // We don't use an arrow function as we'll need the this object + return `/catalog/author/${this._id}`; +}); + +const dateFormatter = new Intl.DateTimeFormat("en-US", { + year: "numeric", + month: "short", + day: "numeric", }); AuthorSchema.virtual("lifespan").get(function () { - let lifetime_string = ""; - if (this.date_of_birth) { - lifetime_string = DateTime.fromJSDate(this.date_of_birth).toLocaleString( - DateTime.DATE_MED - ); - } - lifetime_string += " - "; - if (this.date_of_death) { - lifetime_string += DateTime.fromJSDate(this.date_of_death).toLocaleString( - DateTime.DATE_MED - ); - } - return lifetime_string; + const birth = this.date_of_birth ? dateFormatter.format(this.date_of_birth) : ""; + const death = this.date_of_death ? dateFormatter.format(this.date_of_death) : ""; + return `${birth} - ${death}`; }); AuthorSchema.virtual("date_of_birth_yyyy_mm_dd").get(function () { - return DateTime.fromJSDate(this.date_of_birth).toISODate(); // format 'YYYY-MM-DD' + return this.date_of_birth ? this.date_of_birth.toISOString().slice(0, 10) : ""; }); AuthorSchema.virtual("date_of_death_yyyy_mm_dd").get(function () { - return DateTime.fromJSDate(this.date_of_death).toISODate(); // format 'YYYY-MM-DD' + return this.date_of_death ? this.date_of_death.toISOString().slice(0, 10) : ""; }); -// Export model. -module.exports = mongoose.model("Author", AuthorSchema); +// Export model +export default mongoose.model("Author", AuthorSchema); diff --git a/models/book.js b/models/book.js index a721c943..370654a3 100644 --- a/models/book.js +++ b/models/book.js @@ -1,19 +1,20 @@ -const mongoose = require("mongoose"); +import mongoose from "mongoose"; const Schema = mongoose.Schema; const BookSchema = new Schema({ title: { type: String, required: true }, - author: { type: Schema.ObjectId, ref: "Author", required: true }, + author: { type: Schema.Types.ObjectId, ref: "Author", required: true }, summary: { type: String, required: true }, isbn: { type: String, required: true }, - genre: [{ type: Schema.ObjectId, ref: "Genre" }], + genre: [{ type: Schema.Types.ObjectId, ref: "Genre" }], }); -// Virtual for this book instance URL. +// Virtual for book's URL BookSchema.virtual("url").get(function () { - return "/catalog/book/" + this._id; + // We don't use an arrow function as we'll need the this object + return `/catalog/book/${this._id}`; }); -// Export model. -module.exports = mongoose.model("Book", BookSchema); +// Export model +export default mongoose.model("Book", BookSchema); diff --git a/models/bookinstance.js b/models/bookinstance.js index 8cea912b..98765b9e 100644 --- a/models/bookinstance.js +++ b/models/bookinstance.js @@ -1,10 +1,9 @@ -const mongoose = require("mongoose"); -const { DateTime } = require("luxon"); //for date handling +import mongoose from "mongoose"; const Schema = mongoose.Schema; const BookInstanceSchema = new Schema({ - book: { type: Schema.ObjectId, ref: "Book", required: true }, // Reference to the associated book. + book: { type: Schema.Types.ObjectId, ref: "Book", required: true }, // reference to the associated book imprint: { type: String, required: true }, status: { type: String, @@ -15,18 +14,25 @@ const BookInstanceSchema = new Schema({ due_back: { type: Date, default: Date.now }, }); -// Virtual for this bookinstance object's URL. +// Virtual for bookinstance's URL BookInstanceSchema.virtual("url").get(function () { - return "/catalog/bookinstance/" + this._id; + // We don't use an arrow function as we'll need the this object + return `/catalog/bookinstance/${this._id}`; +}); + +const dateFormatter = new Intl.DateTimeFormat("en-US", { + year: "numeric", + month: "short", + day: "numeric", }); BookInstanceSchema.virtual("due_back_formatted").get(function () { - return DateTime.fromJSDate(this.due_back).toLocaleString(DateTime.DATE_MED); + return dateFormatter.format(this.due_back); }); BookInstanceSchema.virtual("due_back_yyyy_mm_dd").get(function () { - return DateTime.fromJSDate(this.due_back).toISODate(); //format 'YYYY-MM-DD' + return this.due_back ? this.due_back.toISOString().slice(0, 10) : ""; }); -// Export model. -module.exports = mongoose.model("BookInstance", BookInstanceSchema); +// Export model +export default mongoose.model("BookInstance", BookInstanceSchema); diff --git a/models/genre.js b/models/genre.js index af696135..28eb7495 100644 --- a/models/genre.js +++ b/models/genre.js @@ -1,4 +1,4 @@ -const mongoose = require("mongoose"); +import mongoose from "mongoose"; const Schema = mongoose.Schema; @@ -6,10 +6,8 @@ const GenreSchema = new Schema({ name: { type: String, required: true, minLength: 3, maxLength: 100 }, }); -// Virtual for this genre instance URL. GenreSchema.virtual("url").get(function () { - return "/catalog/genre/" + this._id; + return `/catalog/genre/${this._id}`; }); -// Export model. -module.exports = mongoose.model("Genre", GenreSchema); +export default mongoose.model("Genre", GenreSchema); diff --git a/package-lock.json b/package-lock.json index 8b612d5c..bce5dcc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,60 +1,57 @@ { "name": "express-locallibrary-tutorial", - "version": "0.0.1", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "express-locallibrary-tutorial", - "version": "0.0.1", - "dependencies": { - "compression": "^1.8.0", - "cookie-parser": "^1.4.7", - "debug": "^4.4.1", - "express": "^5.1.0", - "express-rate-limit": "^7.5.1", - "express-validator": "^7.3.1", - "helmet": "^8.1.0", - "http-errors": "^2.0.0", - "luxon": "^3.6.1", - "mongoose": "^9.2.1", - "morgan": "^1.10.0", - "pug": "^3.0.3" + "version": "1.0.0", + "dependencies": { + "compression": "^1.8.1", + "debug": "^4.4.3", + "express": "^5.2.1", + "express-rate-limit": "^8.7.0", + "express-validator": "^7.3.2", + "helmet": "^8.3.0", + "http-errors": "^2.0.1", + "mongoose": "^9.9.5", + "morgan": "^1.12.0", + "pug": "^3.0.4" }, "devDependencies": { "mongodb-memory-server": "^10.1.4", - "nodemon": "^3.1.10", "supertest": "^7.1.1" }, "engines": { - "node": ">=22.0.0" + "node": ">=24.0.0" } }, "node_modules/@babel/helper-string-parser": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", - "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", - "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.28.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.0.tgz", - "integrity": "sha512-jVZGvOxOuNSsuQuLRTh13nU0AogFlw32w/MT+LV6D3sP5WdbW61E77RnkbaO2dUvmPAYrBDJXGn5gGS6tH4j8g==", + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.8.tgz", + "integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==", "license": "MIT", "dependencies": { - "@babel/types": "^7.28.0" + "@babel/types": "^7.29.8" }, "bin": { "parser": "bin/babel-parser.js" @@ -64,22 +61,22 @@ } }, "node_modules/@babel/types": { - "version": "7.28.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.0.tgz", - "integrity": "sha512-jYnje+JyZG5YThjHiF28oT4SIZLnYOcSBb6+SDaFIyzDVSkXQmQQYclJ2R+YxcdmK0AX6x1E5OQNtuh3jHDrUg==", + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.27.1", - "@babel/helper-validator-identifier": "^7.27.1" + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@mongodb-js/saslprep": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.3.0.tgz", - "integrity": "sha512-zlayKCsIjYb7/IdfqxorK5+xUMyi4vOKcFy10wKJYc63NSdKI8mNME+uJqfatkPmOSMMUiojrL58IePKBm3gvQ==", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.5.4.tgz", + "integrity": "sha512-05UC0jQsjKAOuXQ0H9Ud9vUTJpZIg+n/FinpR30tI5I8pY2inTfPOZ5OF/cg3Ce/N9MoD1xhRCeOsJtuTbFYlw==", "license": "MIT", "dependencies": { "sparse-bitfield": "^3.0.3" @@ -99,15 +96,21 @@ } }, "node_modules/@paralleldrive/cuid2": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/@paralleldrive/cuid2/-/cuid2-2.2.2.tgz", - "integrity": "sha512-ZOBkgDwEdoYVlSeRbYYXs0S9MejQofiVYoTbKzy/6GQa39/q5tQU2IX46+shYnUkpEl3wc+J6wRlar7r2EK2xA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@paralleldrive/cuid2/-/cuid2-2.3.1.tgz", + "integrity": "sha512-XO7cAxhnTZl0Yggq6jOgjiOHhbgcO4NqFqwSmQpjK3b6TEE6Uj/jfSk6wzYyemh3+I0sHirKSetjQwn5cZktFw==", "dev": true, "license": "MIT", "dependencies": { "@noble/hashes": "^1.1.5" } }, + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", + "license": "MIT" + }, "node_modules/@types/webidl-conversions": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", @@ -115,10 +118,9 @@ "license": "MIT" }, "node_modules/@types/whatwg-url": { - "version": "11.0.5", - "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", - "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", - "dev": true, + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-13.0.0.tgz", + "integrity": "sha512-N8WXpbE6Wgri7KUSvrmQcqrMllKZ9uxkYWMt+mCSGwNc0Hsw9VQTW7ApqI4XNrx6/SaM2QQJCzMPDEXE058s+Q==", "license": "MIT", "dependencies": { "@types/webidl-conversions": "*" @@ -137,15 +139,6 @@ "node": ">= 0.6" } }, - "node_modules/accepts/node_modules/negotiator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", - "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, "node_modules/acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", @@ -168,20 +161,6 @@ "node": ">= 14" } }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "license": "ISC", - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/asap": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", @@ -212,11 +191,19 @@ "license": "MIT" }, "node_modules/b4a": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.7.tgz", - "integrity": "sha512-OnAYlL5b7LEkALw87fUVafQw5rVR9RjwGd4KUwNQ6DrrNmaVaUCgLipfVlzrPQ4tWOR9P0IXGNOx50jYCCdSJg==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.8.1.tgz", + "integrity": "sha512-aiqre1Nr0B/6DgE2N5vwTc+2/oQZ4Wh1t4NznYY4E00y8LCt6NqdRv81so00oo27D8MVKTpUa/MwUUtBLXCoDw==", "dev": true, - "license": "Apache-2.0" + "license": "Apache-2.0", + "peerDependencies": { + "react-native-b4a": "*" + }, + "peerDependenciesMeta": { + "react-native-b4a": { + "optional": true + } + } }, "node_modules/babel-walk": { "version": "3.0.0-canary-5", @@ -230,20 +217,90 @@ "node": ">= 10.0.0" } }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "node_modules/bare-events": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.9.2.tgz", + "integrity": "sha512-AIPKioV7/Y/8KfZ3AAhjPJxLLbY49S64Ym5DakZlUg75qQiTgUq9hEJoEwa4eUezPUlXRy/i5NpsKvo9jgKmoA==", "dev": true, - "license": "MIT" + "license": "Apache-2.0", + "peerDependencies": { + "bare-abort-controller": "*" + }, + "peerDependenciesMeta": { + "bare-abort-controller": { + "optional": true + } + } }, - "node_modules/bare-events": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.6.0.tgz", - "integrity": "sha512-EKZ5BTXYExaNqi3I3f9RtEsaI/xBSGjE0XZCZilPzFAV/goswFHuPd9jEZlPIZ/iNZJwDSao9qRiScySz7MbQg==", + "node_modules/bare-fs": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.8.1.tgz", + "integrity": "sha512-N1nnXdHZAOSstz0XiHikGS4HGMH4CnSwhqWdGQQMqqdvp4Jybm9sE3R1WVnpWVd4SFkc8ryPDBLViNLwiEqECg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bare-events": "^2.5.4", + "bare-path": "^3.0.0", + "bare-stream": "^2.6.4", + "bare-url": "^2.2.2", + "fast-fifo": "^1.3.2" + }, + "engines": { + "bare": ">=1.28.0" + }, + "peerDependencies": { + "bare-buffer": "*" + }, + "peerDependenciesMeta": { + "bare-buffer": { + "optional": true + } + } + }, + "node_modules/bare-path": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.1.2.tgz", + "integrity": "sha512-ZyKbsuuqK6Ag0K8pX6V5Txq6XeJRvY+wXucnFGRjiyVYP9YWDpIQugk/b+enRYrEYBJaqLzghRQpXPMR7341Nw==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/bare-stream": { + "version": "2.13.4", + "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.13.4.tgz", + "integrity": "sha512-PcrQ8lVLbiJscNm1Kez+Yp4Gy4AHGcN1lzwjvf5NybWen7VvEgUfyfnXYJ2zNqWnzOfCb1Abq6lH8ti0syQszA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "b4a": "^1.8.1", + "streamx": "^2.25.0", + "teex": "^1.0.1" + }, + "peerDependencies": { + "bare-abort-controller": "*", + "bare-buffer": "*", + "bare-events": "*" + }, + "peerDependenciesMeta": { + "bare-abort-controller": { + "optional": true + }, + "bare-buffer": { + "optional": true + }, + "bare-events": { + "optional": true + } + } + }, + "node_modules/bare-url": { + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.5.4.tgz", + "integrity": "sha512-Gxa7UVWBr0/edU1b+TJhn/AZvMQUj9OGspvYsaTYQrAbZA4BOTZGL3LiZxvD+CeMlDH4juwD84+eTAp/bLYW5g==", "dev": true, "license": "Apache-2.0", - "optional": true + "dependencies": { + "bare-path": "^3.0.0" + } }, "node_modules/basic-auth": { "version": "2.0.1", @@ -257,40 +314,21 @@ "node": ">= 0.8" } }, - "node_modules/basic-auth/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "license": "MIT" - }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/body-parser": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz", - "integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz", + "integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==", "license": "MIT", "dependencies": { "bytes": "^3.1.2", - "content-type": "^1.0.5", + "content-type": "^2.0.0", "debug": "^4.4.3", - "http-errors": "^2.0.0", - "iconv-lite": "^0.7.0", + "http-errors": "^2.0.1", + "iconv-lite": "^0.7.2", "on-finished": "^2.4.1", - "qs": "^6.14.1", - "raw-body": "^3.0.1", - "type-is": "^2.0.1" + "qs": "^6.15.2", + "raw-body": "^3.0.2", + "type-is": "^2.1.0" }, "engines": { "node": ">=18" @@ -300,48 +338,26 @@ "url": "https://opencollective.com/express" } }, - "node_modules/brace-expansion": { - "version": "1.1.15", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.15.tgz", - "integrity": "sha512-EwOCDEex4quD37XhqM3omwtMoJjr//isUZz1JopUNWms+4Z2ViyM/k1YIRePpoVNnQhENnxtFjLaxNHrT7xIUg==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "dev": true, + "node_modules/body-parser/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", "license": "MIT", - "dependencies": { - "fill-range": "^7.1.1" - }, "engines": { - "node": ">=8" + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/bson": { - "version": "6.10.4", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.4.tgz", - "integrity": "sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==", - "dev": true, + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/bson/-/bson-7.3.2.tgz", + "integrity": "sha512-1w0ra+ho1cuE+w8jzwgzTFIimFtCfZeCoOsvIPQg6uyFCsp8M29U7bNNf5GrFh88TXbYg1g3TyKUGpd6O7q6zA==", "license": "Apache-2.0", "engines": { - "node": ">=16.20.1" - } - }, - "node_modules/buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": "*" + "node": ">=20.19.0" } }, "node_modules/bytes": { @@ -404,31 +420,6 @@ "is-regex": "^1.0.3" } }, - "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "license": "MIT", - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -504,11 +495,33 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "license": "MIT" }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true, + "node_modules/compression/node_modules/negotiator": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.4.tgz", + "integrity": "sha512-myRT3DiWPHqho5PrJaIRyaMv2kgYf0mUVgBNOYMuCH5Ki1yEiQaf/ZJuQ62nvpc44wL5WDbTX7yGJi1Neevw8w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/compression/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "license": "MIT" }, "node_modules/constantinople": { @@ -522,15 +535,16 @@ } }, "node_modules/content-disposition": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", - "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", + "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", "license": "MIT", - "dependencies": { - "safe-buffer": "5.2.1" - }, "engines": { - "node": ">= 0.6" + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/content-type": { @@ -551,25 +565,15 @@ "node": ">= 0.6" } }, - "node_modules/cookie-parser": { - "version": "1.4.7", - "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.7.tgz", - "integrity": "sha512-nGUvgXnotP3BsjiLX2ypbQnWoGUPIIfHQNZkkC668ntrzGWEZVW70HDEB1qnNGMicPje6EttlIgzo51YSwNQGw==", + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", "license": "MIT", - "dependencies": { - "cookie": "0.7.2", - "cookie-signature": "1.0.6" - }, "engines": { - "node": ">= 0.8.0" + "node": ">=6.6.0" } }, - "node_modules/cookie-signature": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", - "license": "MIT" - }, "node_modules/cookiejar": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", @@ -678,9 +682,9 @@ } }, "node_modules/es-object-atoms": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", - "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", "license": "MIT", "dependencies": { "es-errors": "^1.3.0" @@ -720,19 +724,30 @@ "node": ">= 0.6" } }, + "node_modules/events-universal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz", + "integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bare-events": "^2.7.0" + } + }, "node_modules/express": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", - "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", "license": "MIT", "dependencies": { "accepts": "^2.0.0", - "body-parser": "^2.2.0", + "body-parser": "^2.2.1", "content-disposition": "^1.0.0", "content-type": "^1.0.5", "cookie": "^0.7.1", "cookie-signature": "^1.2.1", "debug": "^4.4.0", + "depd": "^2.0.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", @@ -763,10 +778,14 @@ } }, "node_modules/express-rate-limit": { - "version": "7.5.1", - "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.1.tgz", - "integrity": "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.7.0.tgz", + "integrity": "sha512-hOwV7WOxXfjRpAM1DSJWZDXx3GhplwD8IfwuwvogD8i1Qnkgosw/H45s4ZnFAUHDAhPjlY9hLBvJhKmGMyY26g==", "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "ip-address": "^10.2.0" + }, "engines": { "node": ">= 16" }, @@ -778,27 +797,18 @@ } }, "node_modules/express-validator": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/express-validator/-/express-validator-7.3.1.tgz", - "integrity": "sha512-IGenaSf+DnWc69lKuqlRE9/i/2t5/16VpH5bXoqdxWz1aCpRvEdrBuu1y95i/iL5QP8ZYVATiwLFhwk3EDl5vg==", + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/express-validator/-/express-validator-7.3.2.tgz", + "integrity": "sha512-ctLw1Vl6dXVH62dIQMDdTAQkrh480mkFuG6/SGXOaVlwPNukhRAe7EgJIMJ2TSAni8iwHBRp530zAZE5ZPF2IA==", "license": "MIT", "dependencies": { - "lodash": "^4.17.21", + "lodash": "^4.18.1", "validator": "~13.15.23" }, "engines": { "node": ">= 8.0.0" } }, - "node_modules/express/node_modules/cookie-signature": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", - "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", - "license": "MIT", - "engines": { - "node": ">=6.6.0" - } - }, "node_modules/fast-fifo": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", @@ -813,23 +823,10 @@ "dev": true, "license": "MIT" }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "license": "MIT", - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/finalhandler": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", - "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", "license": "MIT", "dependencies": { "debug": "^4.4.0", @@ -840,7 +837,11 @@ "statuses": "^2.0.1" }, "engines": { - "node": ">= 0.8" + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/find-cache-dir": { @@ -897,17 +898,17 @@ } }, "node_modules/form-data": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", - "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", "dev": true, "license": "MIT", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", - "hasown": "^2.0.2", - "mime-types": "^2.1.12" + "hasown": "^2.0.4", + "mime-types": "^2.1.35" }, "engines": { "node": ">= 6" @@ -972,21 +973,6 @@ "node": ">= 0.8" } }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -1033,19 +1019,6 @@ "node": ">= 0.4" } }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/gopd": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", @@ -1058,16 +1031,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/has-symbols": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", @@ -1096,9 +1059,9 @@ } }, "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -1108,12 +1071,15 @@ } }, "node_modules/helmet": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/helmet/-/helmet-8.1.0.tgz", - "integrity": "sha512-jOiHyAZsmnr8LqoPGmCjYAaiuWwjAPLgY8ZX2XrmHawt99/u1y6RgrZMTeoPfpUbV96HOalYgz1qzkRbw54Pmg==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/helmet/-/helmet-8.3.0.tgz", + "integrity": "sha512-Qgpiaws3Sm30Av8Eah6sjMCZZwjlBu+E68rhpCWBshY1lb09HtLwj5GviX0OyQIn+ulUS0iX0AxN5n3tLZzz1w==", "license": "MIT", "engines": { "node": ">=18.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/EvanHahn" } }, "node_modules/http-errors": { @@ -1151,9 +1117,9 @@ } }, "node_modules/iconv-lite": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", - "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" @@ -1166,19 +1132,21 @@ "url": "https://opencollective.com/express" } }, - "node_modules/ignore-by-default": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", - "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", - "dev": true, - "license": "ISC" - }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "license": "ISC" }, + "node_modules/ip-address": { + "version": "10.7.0", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.0.tgz", + "integrity": "sha512-BGFsyJd5mpXp3rK6jIdADLNgpJUK1jnjzvYF8lK+VyDab9JAmqN0YOKDdP17HlgKb2+ehPgDc8EtnRLbGCAMhA==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -1188,26 +1156,13 @@ "node": ">= 0.10" } }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "license": "MIT", - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/is-core-module": { - "version": "2.16.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", - "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.2.tgz", + "integrity": "sha512-evOr8xfXKxE6qSR0hSXL2r3sd7ALj8+7jQEUvPYcm5sgZFdJ+AYzT6yNmJenvIYQBgIGwfwz08sL8zoL7yq2BA==", "license": "MIT", "dependencies": { - "hasown": "^2.0.2" + "hasown": "^2.0.3" }, "engines": { "node": ">= 0.4" @@ -1226,39 +1181,6 @@ "object-assign": "^4.1.1" } }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, "node_modules/is-promise": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", @@ -1300,9 +1222,9 @@ } }, "node_modules/kareem": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/kareem/-/kareem-3.2.0.tgz", - "integrity": "sha512-VS8MWZz/cT+SqBCpVfNN4zoVz5VskR3N4+sTmUXme55e9avQHntpwpNq0yjnosISXqwJ3AQVjlbI4Dyzv//JtA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-3.3.0.tgz", + "integrity": "sha512-kpSuLD3/7RenBnjnJdOHXCKC8dTd1JzeOiJhN0necWWci6cC+qX+VuwPnMVgb+a4+KNJSfgqahpnfWaeDXCimw==", "license": "Apache-2.0", "engines": { "node": ">=18.0.0" @@ -1327,15 +1249,6 @@ "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", "license": "MIT" }, - "node_modules/luxon": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.7.1.tgz", - "integrity": "sha512-RkRWjA926cTvz5rAb1BqyWkKbbjzCGchDUIKMCUvNi17j6f6j8uHGDV82Aqcqtzd+icoYpELmG3ksgGiFNNcNg==", - "license": "MIT", - "engines": { - "node": ">=12" - } - }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -1372,12 +1285,16 @@ } }, "node_modules/media-typer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", - "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz", + "integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==", "license": "MIT", "engines": { "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/memory-pager": { @@ -1431,52 +1348,42 @@ } }, "node_modules/mime-types": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", - "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", "license": "MIT", "dependencies": { "mime-db": "^1.54.0" }, "engines": { - "node": ">= 0.6" - } - }, - "node_modules/minimatch": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", - "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" + "node": ">=18" }, - "engines": { - "node": "*" + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/mongodb": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.17.0.tgz", - "integrity": "sha512-neerUzg/8U26cgruLysKEjJvoNSXhyID3RvzvdcpsIi2COYM3FS3o9nlH7fxFtefTb942dX3W9i37oPfCVj4wA==", - "dev": true, + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-7.5.0.tgz", + "integrity": "sha512-5FnrEDLnvp6ycUOGLNLLU33BfCx2qmp2mJjGPDwKLruYsVzXVSK5fsGpoDXvsXJwBfBsD7ebMRdawbDxC2814g==", "license": "Apache-2.0", "dependencies": { - "@mongodb-js/saslprep": "^1.1.9", - "bson": "^6.10.4", - "mongodb-connection-string-url": "^3.0.0" + "@mongodb-js/saslprep": "^1.4.11", + "bson": "^7.2.0", + "mongodb-connection-string-url": "^7.0.1" }, "engines": { - "node": ">=16.20.1" + "node": ">=20.19.0" }, "peerDependencies": { - "@aws-sdk/credential-providers": "^3.188.0", - "@mongodb-js/zstd": "^1.1.0 || ^2.0.0", - "gcp-metadata": "^5.2.0", - "kerberos": "^2.0.1", - "mongodb-client-encryption": ">=6.0.0 <7", - "snappy": "^7.2.2", - "socks": "^2.7.1" + "@aws-sdk/credential-providers": "^3.806.0", + "@mongodb-js/zstd": "^7.0.0", + "gcp-metadata": "^7.0.1", + "kerberos": "^7.0.0", + "mongodb-client-encryption": "^7.2.0", + "snappy": "^7.3.2", + "socks": "^2.8.6" }, "peerDependenciesMeta": { "@aws-sdk/credential-providers": { @@ -1503,115 +1410,99 @@ } }, "node_modules/mongodb-connection-string-url": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.2.tgz", - "integrity": "sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==", - "dev": true, + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-7.0.2.tgz", + "integrity": "sha512-ZoS07RoFqpKYQwAk59qmrx8+jJHNHU30UjlU96QktiGn1ltvDr+vCznLX5DiUBLEpMAHatHNWV1nM/74ul66kA==", "license": "Apache-2.0", "dependencies": { - "@types/whatwg-url": "^11.0.2", - "whatwg-url": "^14.1.0 || ^13.0.0" + "@types/whatwg-url": "^13.0.0", + "whatwg-url": "^14.1.0" + }, + "engines": { + "node": ">=20.19.0" } }, "node_modules/mongodb-memory-server": { - "version": "10.1.4", - "resolved": "https://registry.npmjs.org/mongodb-memory-server/-/mongodb-memory-server-10.1.4.tgz", - "integrity": "sha512-+oKQ/kc3CX+816oPFRtaF0CN4vNcGKNjpOQe4bHo/21A3pMD+lC7Xz1EX5HP7siCX4iCpVchDMmCOFXVQSGkUg==", + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/mongodb-memory-server/-/mongodb-memory-server-10.4.3.tgz", + "integrity": "sha512-CDZvFisXvGIigsIw5gqH6r9NI/zxGa/uRdutgUL/isuJh+inj0YXb7Ykw6oFMFzqgTJWb7x0I5DpzrqCstBWpg==", "dev": true, "hasInstallScript": true, "license": "MIT", "dependencies": { - "mongodb-memory-server-core": "10.1.4", - "tslib": "^2.7.0" + "mongodb-memory-server-core": "10.4.3", + "tslib": "^2.8.1" }, "engines": { "node": ">=16.20.1" } }, "node_modules/mongodb-memory-server-core": { - "version": "10.1.4", - "resolved": "https://registry.npmjs.org/mongodb-memory-server-core/-/mongodb-memory-server-core-10.1.4.tgz", - "integrity": "sha512-o8fgY7ZalEd8pGps43fFPr/hkQu1L8i6HFEGbsTfA2zDOW0TopgpswaBCqDr0qD7ptibyPfB5DmC+UlIxbThzA==", + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/mongodb-memory-server-core/-/mongodb-memory-server-core-10.4.3.tgz", + "integrity": "sha512-IPjlw73IoSYopnqBibQKxmAXMbOEPf5uGAOsBcaUiNH/TOI7V19WO+K7n5KYtnQ9FqzLGLpvwCGuPOTBSg4s5Q==", "dev": true, "license": "MIT", "dependencies": { "async-mutex": "^0.5.0", "camelcase": "^6.3.0", - "debug": "^4.3.7", + "debug": "^4.4.3", "find-cache-dir": "^3.3.2", - "follow-redirects": "^1.15.9", - "https-proxy-agent": "^7.0.5", + "follow-redirects": "^1.15.11", + "https-proxy-agent": "^7.0.6", "mongodb": "^6.9.0", "new-find-package-json": "^2.0.0", - "semver": "^7.6.3", + "semver": "^7.7.3", "tar-stream": "^3.1.7", - "tslib": "^2.7.0", - "yauzl": "^3.1.3" + "tslib": "^2.8.1", + "yauzl": "^3.2.0" }, "engines": { "node": ">=16.20.1" } }, - "node_modules/mongoose": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-9.2.1.tgz", - "integrity": "sha512-fmNLwgct5km7iL1MqvTMncarR1E1TIw2lmc9A4UoDVdS7AQe95K+DnRK0qATkSUdwUC9V/5wlDcqnkQQjbSRkA==", - "license": "MIT", - "dependencies": { - "kareem": "3.2.0", - "mongodb": "~7.0", - "mpath": "0.9.0", - "mquery": "6.0.0", - "ms": "2.1.3", - "sift": "17.1.3" - }, - "engines": { - "node": ">=20.19.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mongoose" - } - }, - "node_modules/mongoose/node_modules/@types/whatwg-url": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-13.0.0.tgz", - "integrity": "sha512-N8WXpbE6Wgri7KUSvrmQcqrMllKZ9uxkYWMt+mCSGwNc0Hsw9VQTW7ApqI4XNrx6/SaM2QQJCzMPDEXE058s+Q==", + "node_modules/mongodb-memory-server-core/node_modules/@types/whatwg-url": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", + "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", + "dev": true, "license": "MIT", "dependencies": { "@types/webidl-conversions": "*" } }, - "node_modules/mongoose/node_modules/bson": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-7.2.0.tgz", - "integrity": "sha512-YCEo7KjMlbNlyHhz7zAZNDpIpQbd+wOEHJYezv0nMYTn4x31eIUM2yomNNubclAt63dObUzKHWsBLJ9QcZNSnQ==", + "node_modules/mongodb-memory-server-core/node_modules/bson": { + "version": "6.10.4", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.4.tgz", + "integrity": "sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==", + "dev": true, "license": "Apache-2.0", "engines": { - "node": ">=20.19.0" + "node": ">=16.20.1" } }, - "node_modules/mongoose/node_modules/mongodb": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-7.0.0.tgz", - "integrity": "sha512-vG/A5cQrvGGvZm2mTnCSz1LUcbOPl83hfB6bxULKQ8oFZauyox/2xbZOoGNl+64m8VBrETkdGCDBdOsCr3F3jg==", + "node_modules/mongodb-memory-server-core/node_modules/mongodb": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.21.0.tgz", + "integrity": "sha512-URyb/VXMjJ4da46OeSXg+puO39XH9DeQpWCslifrRn9JWugy0D+DvvBvkm2WxmHe61O/H19JM66p1z7RHVkZ6A==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@mongodb-js/saslprep": "^1.3.0", - "bson": "^7.0.0", - "mongodb-connection-string-url": "^7.0.0" + "bson": "^6.10.4", + "mongodb-connection-string-url": "^3.0.2" }, "engines": { - "node": ">=20.19.0" + "node": ">=16.20.1" }, "peerDependencies": { - "@aws-sdk/credential-providers": "^3.806.0", - "@mongodb-js/zstd": "^7.0.0", - "gcp-metadata": "^7.0.1", - "kerberos": "^7.0.0", - "mongodb-client-encryption": ">=7.0.0 <7.1.0", + "@aws-sdk/credential-providers": "^3.188.0", + "@mongodb-js/zstd": "^1.1.0 || ^2.0.0", + "gcp-metadata": "^5.2.0", + "kerberos": "^2.0.1", + "mongodb-client-encryption": ">=6.0.0 <7", "snappy": "^7.3.2", - "socks": "^2.8.6" + "socks": "^2.7.1" }, "peerDependenciesMeta": { "@aws-sdk/credential-providers": { @@ -1637,33 +1528,57 @@ } } }, - "node_modules/mongoose/node_modules/mongodb-connection-string-url": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-7.0.1.tgz", - "integrity": "sha512-h0AZ9A7IDVwwHyMxmdMXKy+9oNlF0zFoahHiX3vQ8e3KFcSP3VmsmfvtRSuLPxmyv2vjIDxqty8smTgie/SNRQ==", + "node_modules/mongodb-memory-server-core/node_modules/mongodb-connection-string-url": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.2.tgz", + "integrity": "sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==", + "dev": true, "license": "Apache-2.0", "dependencies": { - "@types/whatwg-url": "^13.0.0", - "whatwg-url": "^14.1.0" + "@types/whatwg-url": "^11.0.2", + "whatwg-url": "^14.1.0 || ^13.0.0" + } + }, + "node_modules/mongoose": { + "version": "9.9.5", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-9.9.5.tgz", + "integrity": "sha512-t/kUoeDjlHmav7yCaq//YKU3wiIgUPaTj4GrluiTHUw4jQ77/CXtdMDSor4f1u3SKLhIK6NgCF+AzzUqU02Aag==", + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.1.0", + "kareem": "3.3.0", + "mongodb": "~7.5", + "mpath": "0.9.0", + "mquery": "6.0.0", + "ms": "2.1.3", + "sift": "17.1.3" }, "engines": { "node": ">=20.19.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mongoose" } }, "node_modules/morgan": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.1.tgz", - "integrity": "sha512-223dMRJtI/l25dJKWpgij2cMtywuG/WiUKXdvwfbhGKBhy1puASqXwFzmWZ7+K73vUPoR7SS2Qz2cI/g9MKw0A==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.12.0.tgz", + "integrity": "sha512-OHpTRQwn2ezasILW8iKe+Yww1XsfWsZIpUOLF7RDb2g5GwO3trPaRwi7+8BDiJ7HFx2Kg2mfUdCBcVhwYlOz2g==", "license": "MIT", "dependencies": { "basic-auth": "~2.0.1", "debug": "2.6.9", "depd": "~2.0.0", - "on-finished": "~2.3.0", + "on-finished": "~2.4.1", "on-headers": "~1.1.0" }, "engines": { "node": ">= 0.8.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/morgan/node_modules/debug": { @@ -1681,18 +1596,6 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "license": "MIT" }, - "node_modules/morgan/node_modules/on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", - "license": "MIT", - "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/mpath": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", @@ -1718,64 +1621,45 @@ "license": "MIT" }, "node_modules/negotiator": { - "version": "0.6.4", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.4.tgz", - "integrity": "sha512-myRT3DiWPHqho5PrJaIRyaMv2kgYf0mUVgBNOYMuCH5Ki1yEiQaf/ZJuQ62nvpc44wL5WDbTX7yGJi1Neevw8w==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/new-find-package-json": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/new-find-package-json/-/new-find-package-json-2.0.0.tgz", - "integrity": "sha512-lDcBsjBSMlj3LXH2v/FW3txlh2pYTjmbOXPYJD93HI5EwuLzI11tdHSIpUMmfq/IOsldj4Ps8M8flhm+pCK4Ew==", - "dev": true, + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz", + "integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==", "license": "MIT", "dependencies": { - "debug": "^4.3.4" + "content-type": "^2.1.0" }, "engines": { - "node": ">=12.22.0" + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, - "node_modules/nodemon": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz", - "integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==", - "dev": true, + "node_modules/negotiator/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", "license": "MIT", - "dependencies": { - "chokidar": "^3.5.2", - "debug": "^4", - "ignore-by-default": "^1.0.1", - "minimatch": "^3.1.2", - "pstree.remy": "^1.1.8", - "semver": "^7.5.3", - "simple-update-notifier": "^2.0.0", - "supports-color": "^5.5.0", - "touch": "^3.1.0", - "undefsafe": "^2.0.5" - }, - "bin": { - "nodemon": "bin/nodemon.js" - }, "engines": { - "node": ">=10" + "node": ">=18" }, "funding": { "type": "opencollective", - "url": "https://opencollective.com/nodemon" + "url": "https://opencollective.com/express" } }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "node_modules/new-find-package-json": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/new-find-package-json/-/new-find-package-json-2.0.0.tgz", + "integrity": "sha512-lDcBsjBSMlj3LXH2v/FW3txlh2pYTjmbOXPYJD93HI5EwuLzI11tdHSIpUMmfq/IOsldj4Ps8M8flhm+pCK4Ew==", "dev": true, "license": "MIT", + "dependencies": { + "debug": "^4.3.4" + }, "engines": { - "node": ">=0.10.0" + "node": ">=12.22.0" } }, "node_modules/object-assign": { @@ -1910,19 +1794,6 @@ "dev": true, "license": "MIT" }, - "node_modules/picomatch": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", - "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", @@ -1958,20 +1829,13 @@ "node": ">= 0.10" } }, - "node_modules/pstree.remy": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", - "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", - "dev": true, - "license": "MIT" - }, "node_modules/pug": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/pug/-/pug-3.0.3.tgz", - "integrity": "sha512-uBi6kmc9f3SZ3PXxqcHiUZLmIXgfgWooKWXcwSGwQd2Zi5Rb0bT14+8CJjJgI8AB+nndLaNgHGrcc6bPIB665g==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/pug/-/pug-3.0.4.tgz", + "integrity": "sha512-kFfq5mMzrS7+wrl5pLJzZEzemx34OQ0w4SARfhy/3yxTlhbstsudDwJzhf1hP02yHzbjoVMSXUj/Sz6RNfMyXg==", "license": "MIT", "dependencies": { - "pug-code-gen": "^3.0.3", + "pug-code-gen": "^3.0.4", "pug-filters": "^4.0.0", "pug-lexer": "^5.0.1", "pug-linker": "^4.0.0", @@ -1993,9 +1857,9 @@ } }, "node_modules/pug-code-gen": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/pug-code-gen/-/pug-code-gen-3.0.3.tgz", - "integrity": "sha512-cYQg0JW0w32Ux+XTeZnBEeuWrAY7/HNE6TWnhiHGnnRYlCgyAUPoyh9KzCMa9WhcJlJ1AtQqpEYHc+vbCzA+Aw==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/pug-code-gen/-/pug-code-gen-3.0.4.tgz", + "integrity": "sha512-6okWYIKdasTyXICyEtvobmTZAVX57JkzgzIi4iRJlin8kmhG+Xry2dsus+Mun/nGCn6F2U49haHI5mkELXB14g==", "license": "MIT", "dependencies": { "constantinople": "^4.0.1", @@ -2099,12 +1963,13 @@ } }, "node_modules/qs": { - "version": "6.15.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz", - "integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==", + "version": "6.16.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", + "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==", "license": "BSD-3-Clause", "dependencies": { - "side-channel": "^1.1.0" + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" }, "engines": { "node": ">=0.6" @@ -2114,12 +1979,16 @@ } }, "node_modules/range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz", + "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==", "license": "MIT", "engines": { "node": ">= 0.6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/raw-body": { @@ -2137,26 +2006,14 @@ "node": ">= 0.10" } }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "license": "MIT", - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, "node_modules/resolve": { - "version": "1.22.10", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", - "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", + "version": "1.22.12", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.12.tgz", + "integrity": "sha512-TyeJ1zif53BPfHootBGwPRYT1RUt6oGWsaQr8UyZW/eAm9bKoijtvruSDEmZHm92CwS9nj7/fWttqPCgzep8CA==", "license": "MIT", "dependencies": { - "is-core-module": "^2.16.0", + "es-errors": "^1.3.0", + "is-core-module": "^2.16.1", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, @@ -2193,23 +2050,9 @@ "license": "MIT" }, "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "license": "MIT" }, "node_modules/safer-buffer": { @@ -2219,9 +2062,9 @@ "license": "MIT" }, "node_modules/semver": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", - "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", "dev": true, "license": "ISC", "bin": { @@ -2232,31 +2075,35 @@ } }, "node_modules/send": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", - "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", "license": "MIT", "dependencies": { - "debug": "^4.3.5", + "debug": "^4.4.3", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "fresh": "^2.0.0", - "http-errors": "^2.0.0", - "mime-types": "^3.0.1", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", "ms": "^2.1.3", "on-finished": "^2.4.1", "range-parser": "^1.2.1", - "statuses": "^2.0.1" + "statuses": "^2.0.2" }, "engines": { "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/serve-static": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", - "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", "license": "MIT", "dependencies": { "encodeurl": "^2.0.0", @@ -2266,6 +2113,10 @@ }, "engines": { "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/setprototypeof": { @@ -2275,14 +2126,14 @@ "license": "ISC" }, "node_modules/side-channel": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", - "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", "license": "MIT", "dependencies": { "es-errors": "^1.3.0", - "object-inspect": "^1.13.3", - "side-channel-list": "^1.0.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", "side-channel-map": "^1.0.1", "side-channel-weakmap": "^1.0.2" }, @@ -2294,13 +2145,13 @@ } }, "node_modules/side-channel-list": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", - "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", "license": "MIT", "dependencies": { "es-errors": "^1.3.0", - "object-inspect": "^1.13.3" + "object-inspect": "^1.13.4" }, "engines": { "node": ">= 0.4" @@ -2352,19 +2203,6 @@ "integrity": "sha512-Rtlj66/b0ICeFzYTuNvX/EF1igRbbnGSvEyT79McoZa/DeGhMyC5pWKOEsZKnpkqtSeovd5FL/bjHWC3CIIvCQ==", "license": "MIT" }, - "node_modules/simple-update-notifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", - "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/sparse-bitfield": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", @@ -2384,67 +2222,53 @@ } }, "node_modules/streamx": { - "version": "2.22.1", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.22.1.tgz", - "integrity": "sha512-znKXEBxfatz2GBNK02kRnCXjV+AA4kjZIUxeWSr3UGirZMJfTE9uiwKHobnbgxWyL/JWro8tTq+vOqAK1/qbSA==", + "version": "2.28.1", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.28.1.tgz", + "integrity": "sha512-zEzXb0s5Cds7tqMH6rhZ05lcJydCWiQPEwiNngVqzsxCc962vLY4Uw+mW7od8kDH258k2Uz/JrOkdIAAhSh9VA==", "dev": true, "license": "MIT", "dependencies": { + "events-universal": "^1.0.0", "fast-fifo": "^1.3.2", "text-decoder": "^1.1.0" - }, - "optionalDependencies": { - "bare-events": "^2.2.0" } }, "node_modules/superagent": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-10.2.2.tgz", - "integrity": "sha512-vWMq11OwWCC84pQaFPzF/VO3BrjkCeewuvJgt1jfV0499Z1QSAWN4EqfMM5WlFDDX9/oP8JjlDKpblrmEoyu4Q==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-10.3.0.tgz", + "integrity": "sha512-B+4Ik7ROgVKrQsXTV0Jwp2u+PXYLSlqtDAhYnkkD+zn3yg8s/zjA2MeGayPoY/KICrbitwneDHrjSotxKL+0XQ==", "dev": true, "license": "MIT", "dependencies": { - "component-emitter": "^1.3.0", + "component-emitter": "^1.3.1", "cookiejar": "^2.1.4", - "debug": "^4.3.4", + "debug": "^4.3.7", "fast-safe-stringify": "^2.1.1", - "form-data": "^4.0.0", + "form-data": "^4.0.5", "formidable": "^3.5.4", "methods": "^1.1.2", "mime": "2.6.0", - "qs": "^6.11.0" + "qs": "^6.14.1" }, "engines": { "node": ">=14.18.0" } }, "node_modules/supertest": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/supertest/-/supertest-7.1.3.tgz", - "integrity": "sha512-ORY0gPa6ojmg/C74P/bDoS21WL6FMXq5I8mawkEz30/zkwdu0gOeqstFy316vHG6OKxqQ+IbGneRemHI8WraEw==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/supertest/-/supertest-7.2.2.tgz", + "integrity": "sha512-oK8WG9diS3DlhdUkcFn4tkNIiIbBx9lI2ClF8K+b2/m8Eyv47LSawxUzZQSNKUrVb2KsqeTDCcjAAVPYaSLVTA==", "dev": true, "license": "MIT", "dependencies": { + "cookie-signature": "^1.2.2", "methods": "^1.1.2", - "superagent": "^10.2.2" + "superagent": "^10.3.0" }, "engines": { "node": ">=14.18.0" } }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", @@ -2458,38 +2282,36 @@ } }, "node_modules/tar-stream": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", - "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.2.1.tgz", + "integrity": "sha512-nqsEO8zLZJvrOMdEwkA0QdCLFbetHMn95Zqu4fKwX+hkaTWJPZZOrxx/PwtxoK0MMGQmBQNRW3CPs8IFYQz4cQ==", "dev": true, "license": "MIT", "dependencies": { "b4a": "^1.6.4", + "bare-fs": "^4.5.5", "fast-fifo": "^1.2.0", "streamx": "^2.15.0" } }, - "node_modules/text-decoder": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.3.tgz", - "integrity": "sha512-3/o9z3X0X0fTupwsYvR03pJ/DjWuqqrfwBgTQzdWDiQSm9KitAyz/9WqsT2JQW7KV2m+bC2ol/zqpW37NHxLaA==", + "node_modules/teex": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/teex/-/teex-1.0.1.tgz", + "integrity": "sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==", "dev": true, - "license": "Apache-2.0", + "license": "MIT", "dependencies": { - "b4a": "^1.6.4" + "streamx": "^2.12.5" } }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "node_modules/text-decoder": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.7.tgz", + "integrity": "sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==", "dev": true, - "license": "MIT", + "license": "Apache-2.0", "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" + "b4a": "^1.6.4" } }, "node_modules/toidentifier": { @@ -2507,16 +2329,6 @@ "integrity": "sha512-VSsyNPPW74RpHwR8Fc21uubwHY7wMDeJLys2IX5zJNih+OnAnaifKHo+1LHT7DAdloQ7apeaaWg8l7qnf/TnEg==", "license": "MIT" }, - "node_modules/touch": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", - "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", - "dev": true, - "license": "ISC", - "bin": { - "nodetouch": "bin/nodetouch.js" - } - }, "node_modules/tr46": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", @@ -2537,25 +2349,35 @@ "license": "0BSD" }, "node_modules/type-is": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", - "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", + "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", "license": "MIT", "dependencies": { - "content-type": "^1.0.5", + "content-type": "^2.0.0", "media-typer": "^1.1.0", "mime-types": "^3.0.0" }, "engines": { - "node": ">= 0.6" + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, - "node_modules/undefsafe": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", - "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", - "dev": true, - "license": "MIT" + "node_modules/type-is/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } }, "node_modules/unpipe": { "version": "1.0.0", @@ -2567,9 +2389,9 @@ } }, "node_modules/validator": { - "version": "13.15.23", - "resolved": "https://registry.npmjs.org/validator/-/validator-13.15.23.tgz", - "integrity": "sha512-4yoz1kEWqUjzi5zsPbAS/903QXSYp0UOtHsPpp7p9rHAw/W+dkInskAE386Fat3oKRROwO98d9ZB0G4cObgUyw==", + "version": "13.15.35", + "resolved": "https://registry.npmjs.org/validator/-/validator-13.15.35.tgz", + "integrity": "sha512-TQ5pAGhd5whStmqWvYF4OjQROlmv9SMFVt37qoCBdqRffuuklWYQlCNnEs2ZaIBD1kZRNnikiZOS1eqgkar0iw==", "license": "MIT", "engines": { "node": ">= 0.10" @@ -2637,13 +2459,12 @@ "license": "ISC" }, "node_modules/yauzl": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-3.3.1.tgz", - "integrity": "sha512-RNPCUkiE/ZgO4w8i9U5yDQVHaFDdnzaFANElRvpJteCspvmv2VqrRb9lvS6odVD+jqI/zDsxAHJVsafpcheVQQ==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-3.4.0.tgz", + "integrity": "sha512-jIH9yLR9wqr0wOS0TpBvo/g/2UgZH5qePVbjgRliiF0BYvOZyaBknKsF+x9Iht0O6sqgnB93rCICdOZFecJuDw==", "dev": true, "license": "MIT", "dependencies": { - "buffer-crc32": "~0.2.3", "pend": "~1.2.0" }, "engines": { diff --git a/package.json b/package.json index ec5be061..f552ce15 100644 --- a/package.json +++ b/package.json @@ -1,33 +1,29 @@ { "name": "express-locallibrary-tutorial", - "version": "0.0.1", - "engines": { - "node": ">=22.0.0" + "version": "1.0.0", + "scripts": { + "start": "node server.js", + "devstart": "node --watch server.js" }, + "type": "module", "private": true, - "scripts": { - "start": "node ./bin/www", - "devstart": "nodemon ./bin/www", - "serverstart": "DEBUG=express-locallibrary-tutorial:* npm run devstart", - "test": "node --test" + "engines": { + "node": ">=24.0.0" }, "dependencies": { - "compression": "^1.8.0", - "cookie-parser": "^1.4.7", - "debug": "^4.4.1", - "express": "^5.1.0", - "express-rate-limit": "^7.5.1", - "express-validator": "^7.3.1", - "helmet": "^8.1.0", - "http-errors": "^2.0.0", - "luxon": "^3.6.1", - "mongoose": "^9.2.1", - "morgan": "^1.10.0", - "pug": "^3.0.3" + "compression": "^1.8.1", + "debug": "^4.4.3", + "express": "^5.2.1", + "express-rate-limit": "^8.7.0", + "express-validator": "^7.3.2", + "helmet": "^8.3.0", + "http-errors": "^2.0.1", + "mongoose": "^9.9.5", + "morgan": "^1.12.0", + "pug": "^3.0.4" }, "devDependencies": { "mongodb-memory-server": "^10.1.4", - "nodemon": "^3.1.10", "supertest": "^7.1.1" }, "allowScripts": { diff --git a/populatedb.js b/populatedb.js index 53e496cb..7cad9ede 100644 --- a/populatedb.js +++ b/populatedb.js @@ -1,37 +1,38 @@ -#! /usr/bin/env node +import createDebug from "debug"; +import mongoose from "mongoose"; -console.log( +import Book from "./models/book.js"; +import Author from "./models/author.js"; +import Genre from "./models/genre.js"; +import BookInstance from "./models/bookinstance.js"; + +const debug = createDebug("express-locallibrary-tutorial:populatedb"); + +debug( 'This script populates some test books, authors, genres and bookinstances to your database. Specified database as argument - e.g.: node populatedb "mongodb+srv://cooluser:coolpassword@cluster0.cojoign.mongodb.net/local_library?retryWrites=true&w=majority&appName=Cluster0"' ); // Get arguments passed on command line const userArgs = process.argv.slice(2); -const Book = require("./models/book"); -const Author = require("./models/author"); -const Genre = require("./models/genre"); -const BookInstance = require("./models/bookinstance"); - const genres = []; const authors = []; const books = []; const bookinstances = []; -const mongoose = require("mongoose"); - const mongoDB = userArgs[0]; -main().catch((err) => console.log(err)); +main().catch((err) => debug(err)); async function main() { - console.log("Debug: About to connect"); + debug("Debug: About to connect"); await mongoose.connect(mongoDB); - console.log("Debug: Should be connected?"); + debug("Debug: Should be connected?"); await createGenres(); await createAuthors(); await createBooks(); await createBookInstances(); - console.log("Debug: Closing mongoose"); + debug("Debug: Closing mongoose"); await mongoose.connection.close(); } @@ -42,7 +43,7 @@ async function genreCreate(index, name) { const genre = new Genre({ name: name }); await genre.save(); genres[index] = genre; - console.log(`Added genre: ${name}`); + debug(`Added genre: ${name}`); } async function authorCreate(index, first_name, family_name, d_birth, d_death) { @@ -54,7 +55,7 @@ async function authorCreate(index, first_name, family_name, d_birth, d_death) { await author.save(); authors[index] = author; - console.log(`Added author: ${first_name} ${family_name}`); + debug(`Added author: ${first_name} ${family_name}`); } async function bookCreate(index, title, summary, isbn, author, genre) { @@ -69,7 +70,7 @@ async function bookCreate(index, title, summary, isbn, author, genre) { const book = new Book(bookdetail); await book.save(); books[index] = book; - console.log(`Added book: ${title}`); + debug(`Added book: ${title}`); } async function bookInstanceCreate(index, book, imprint, due_back, status) { @@ -83,11 +84,11 @@ async function bookInstanceCreate(index, book, imprint, due_back, status) { const bookinstance = new BookInstance(bookinstancedetail); await bookinstance.save(); bookinstances[index] = bookinstance; - console.log(`Added bookinstance: ${imprint}`); + debug(`Added bookinstance: ${imprint}`); } async function createGenres() { - console.log("Adding genres"); + debug("Adding genres"); await Promise.all([ genreCreate(0, "Fantasy"), genreCreate(1, "Science Fiction"), @@ -96,7 +97,7 @@ async function createGenres() { } async function createAuthors() { - console.log("Adding authors"); + debug("Adding authors"); await Promise.all([ authorCreate(0, "Patrick", "Rothfuss", "1973-06-06", false), authorCreate(1, "Ben", "Bova", "1932-11-8", false), @@ -107,7 +108,7 @@ async function createAuthors() { } async function createBooks() { - console.log("Adding Books"); + debug("Adding Books"); await Promise.all([ bookCreate( 0, @@ -169,7 +170,7 @@ async function createBooks() { } async function createBookInstances() { - console.log("Adding authors"); + debug("Adding authors"); await Promise.all([ bookInstanceCreate( 0, diff --git a/public/images/Library Website - Mongoose_Express.png b/public/images/Library Website - Mongoose_Express.png deleted file mode 100644 index 847ccf5668333c59ac9b0448347f0dda772971e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17146 zcmdtKcT`i~7bl7cLO?`9M|u^J-la(gX-e+p?|Y+Ot1A-VQQ=`=U=S!P$!TI> zU?R{zM_hCPh8H%Y68aCzPFhVG1EV$p|Jni@eNS(tq^X91;meAF5e&h=xI`BP?_gkf z@?c=>nqy$R$i%=P2W7Xu5l2^GTB<0@VcbR}jC7&z03am;cMJ@Qth?VmWzW!5bRmw1 zvYI>&0-pkdl9SVUE(QZbdS6*iS{ppSpEKOJS5_Ae2z?qUqnrqFd;P%sVgJj$hUph3 zjIS{p2%UTdJW4SoILAdZ&Sczfthim&_QF*1Tmf%%DwvXTpL==US1Od1hot0kGG?DT z5+MrhVsP0cjO0Xq&N0H2$H|D)eVZadllA|LNiI1Mv8M{;Cc;3Xz~o3|OoJF=)_8Ey zlLny|bQ~iO$zx``W+XzeMd5ZS$)S`PVch>Bl>0YTlNXPjQ(KNt%~YYfdbu~!klu9; z296WkM#~GH(|~aYN(X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6&wMvec^tV%0u`e*QRC|#2PY-On!uE+m-ec<4~{jr6;+k3IC#T}=fF@5N7L9lqp z>w8#Rc-XwKa { res.redirect("/catalog"); }); -module.exports = router; +export default router; diff --git a/routes/users.js b/routes/users.js index c34e5e9d..85b952d1 100644 --- a/routes/users.js +++ b/routes/users.js @@ -1,10 +1,9 @@ -const express = require("express"); +import { Router } from "express"; -const router = express.Router(); +const router = Router(); -/* GET users listing. */ -router.get("/", function (req, res, next) { +router.get("/", (req, res) => { res.send("respond with a resource"); }); -module.exports = router; +export default router; diff --git a/server.js b/server.js new file mode 100644 index 00000000..d62c1cea --- /dev/null +++ b/server.js @@ -0,0 +1,34 @@ +import { createServer } from "node:http"; +import createDebug from "debug"; +import mongoose from "mongoose"; + +import app from "./app.js"; + +const debug = createDebug("express-locallibrary-tutorial:server"); +const port = Number(process.env.PORT ?? 3000); +if (!Number.isInteger(port) || port < 0 || port > 65535) + throw new RangeError("PORT must be an integer between 0 and 65535"); +app.set("port", port); + +const devDbUrl = "mongodb://127.0.0.1:27017/local_library"; +const mongoDB = process.env.MONGODB_URI || devDbUrl; + +mongoose.connection.on("error", (err) => { + console.error("MongoDB connection error:", err); +}); + +mongoose.connection.on("disconnected", () => { + console.warn("MongoDB disconnected"); +}); + +await mongoose.connect(mongoDB); + +const server = createServer(app); +server.on("error", (err) => { + throw new Error("Failed to start server", { cause: err }); +}); +server.on("listening", () => { + const address = server.address(); + debug(`Listening on port ${address.port}`); +}); +server.listen(port); diff --git a/views/author_delete.pug b/views/author_delete.pug index fa14ee9c..62cdb06a 100644 --- a/views/author_delete.pug +++ b/views/author_delete.pug @@ -23,4 +23,4 @@ block content div.form-group input#authorid.form-control(type='hidden', name='authorid', value=author._id ) - button.btn.btn-primary(type='submit') Delete \ No newline at end of file + button.btn.btn-primary(type='submit') Delete diff --git a/views/author_detail.pug b/views/author_detail.pug index aba01ec8..a9b17078 100644 --- a/views/author_detail.pug +++ b/views/author_detail.pug @@ -19,6 +19,6 @@ block content hr p - a(href=author.url+'/delete') Delete author + a(href=author.url+'/delete') Delete Author p - a(href=author.url+'/update') Update author + a(href=author.url+'/update') Update Author diff --git a/views/author_form.pug b/views/author_form.pug index 164fb567..9b6bb806 100644 --- a/views/author_form.pug +++ b/views/author_form.pug @@ -11,13 +11,13 @@ block content input#family_name.form-control(type='text', placeholder='Family name (Surname)' name='family_name' required value=(undefined===author ? '' : author.family_name)) div.form-group label(for='date_of_birth') Date of birth: - input#date_of_birth.form-control(type='date', name='date_of_birth' value=(undefined===author ? '' : author.date_of_birth_yyyy_mm_dd) ) + input#date_of_birth.form-control(type='date' name='date_of_birth' value=(undefined===author ? '' : author.date_of_birth_yyyy_mm_dd) ) div.form-group label(for='date_of_death') Date of death: - input#date_of_death.form-control(type='date', name='date_of_death' value=(undefined===author ? '' : author.date_of_death_yyyy_mm_dd) ) + input#date_of_death.form-control(type='date' name='date_of_death' value=(undefined===author ? '' : author.date_of_death_yyyy_mm_dd)) button.btn.btn-primary(type='submit') Submit if errors ul for error in errors - li!= error.msg \ No newline at end of file + li!= error.msg diff --git a/views/author_list.pug b/views/author_list.pug index 0fd96866..9d3e8dde 100644 --- a/views/author_list.pug +++ b/views/author_list.pug @@ -9,6 +9,5 @@ block content li a(href=author.url) #{author.name} | (#{author.lifespan}) - else p There are no authors. diff --git a/views/book_delete.pug b/views/book_delete.pug index 4c33f538..026cd2f9 100644 --- a/views/book_delete.pug +++ b/views/book_delete.pug @@ -34,7 +34,7 @@ block content p.text-warning #{book_copy.status} p #[strong Imprint:] #{book_copy.imprint} if book_copy.status!='Available' - p #[strong Due back:] #{book_copy.due_back} + p #[strong Due back:] #{book_copy.due_back_formatted} p #[strong Id:] a(href=book_copy.url) #{book_copy._id} diff --git a/views/book_list.pug b/views/book_list.pug index 61f0c80c..3a7c69e0 100644 --- a/views/book_list.pug +++ b/views/book_list.pug @@ -2,12 +2,11 @@ extends layout block content h1= title - if book_list.length ul each book in book_list li - a(href=book.url) #{book.title} + a(href=book.url) !{book.title} | (#{book.author.name}) else diff --git a/views/bookinstance_delete.pug b/views/bookinstance_delete.pug index 84db6044..b910266d 100644 --- a/views/bookinstance_delete.pug +++ b/views/bookinstance_delete.pug @@ -30,4 +30,4 @@ block content div.form-group input#id.form-control(type='hidden',name='id', value=bookinstance._id ) - button.btn.btn-primary(type='submit') Delete \ No newline at end of file + button.btn.btn-primary(type='submit') Delete diff --git a/views/bookinstance_detail.pug b/views/bookinstance_detail.pug index 97d635f3..c476a656 100644 --- a/views/bookinstance_detail.pug +++ b/views/bookinstance_detail.pug @@ -23,4 +23,4 @@ block content p a(href=bookinstance.url+'/delete') Delete BookInstance p - a(href=bookinstance.url+'/update') Update BookInstance \ No newline at end of file + a(href=bookinstance.url+'/update') Update BookInstance diff --git a/views/bookinstance_form.pug b/views/bookinstance_form.pug index 5e0aa43a..8d928cbd 100644 --- a/views/bookinstance_form.pug +++ b/views/bookinstance_form.pug @@ -26,7 +26,7 @@ block content select#status.form-control(name='status' required) option(value='') --Please select a status-- each val in ['Maintenance', 'Available', 'Loaned', 'Reserved'] - if undefined===bookinstance || bookinstance.status!=val + if undefined===bookinstance || bookinstance.status!=val option(value=val)= val else option(value=val selected)= val diff --git a/views/genre_delete.pug b/views/genre_delete.pug index f025ba99..6837d3c8 100644 --- a/views/genre_delete.pug +++ b/views/genre_delete.pug @@ -25,4 +25,4 @@ block content div.form-group input#id.form-control(type='hidden', name='id', value=genre._id ) - button.btn.btn-primary(type='submit') Delete \ No newline at end of file + button.btn.btn-primary(type='submit') Delete diff --git a/views/genre_detail.pug b/views/genre_detail.pug index f3301031..0c049cd2 100644 --- a/views/genre_detail.pug +++ b/views/genre_detail.pug @@ -18,6 +18,6 @@ block content hr p - a(href=genre.url+'/delete') Delete genre + a(href=genre.url+'/delete') Delete Genre p - a(href=genre.url+'/update') Update genre \ No newline at end of file + a(href=genre.url+'/update') Update Genre diff --git a/views/genre_form.pug b/views/genre_form.pug index 5ddf07fd..6c74fe72 100644 --- a/views/genre_form.pug +++ b/views/genre_form.pug @@ -13,4 +13,4 @@ block content if errors ul for error in errors - li!= error.msg \ No newline at end of file + li!= error.msg diff --git a/views/genre_list.pug b/views/genre_list.pug index c23f02eb..2fccfb98 100644 --- a/views/genre_list.pug +++ b/views/genre_list.pug @@ -2,12 +2,11 @@ extends layout block content h1= title - - if list_genres.length + + if genre_list.length ul - each val in list_genres + each genre in genre_list li - a(href=val.url) #{val.name} - + a(href=genre.url) #{genre.name} else p There are no genres. diff --git a/views/index.pug b/views/index.pug index 5c856c74..90b8ae11 100644 --- a/views/index.pug +++ b/views/index.pug @@ -4,7 +4,7 @@ block content h1= title p Welcome to #[em LocalLibrary], a very basic Express website developed as a tutorial example on the Mozilla Developer Network. - h1 Dynamic content + h2 Dynamic content p The library has the following record counts: From b88cc60f48055bb5508d2aba90cc8e753c0e234d Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Tue, 10 Nov 2026 11:19:13 +1100 Subject: [PATCH 2/4] Fix npm test, populatedb output and README; add npm run demo - Restore the "test" script so `npm test` works again. - populatedb.js: log progress with console.log (as the guide describes), report failures with a non-zero exit code, and show a usage message with a local MongoDB URL example instead of Atlas credentials. - Add demo.js and `npm run demo`, which runs the site against a temporary in-memory database filled with the sample data. - README: describe the demo, the local MongoDB default (install, Docker or Atlas via MONGODB_URI), consistent start commands, the MDN-hosted data model diagram, and current MDN links. Co-Authored-By: Claude Opus 5.5 --- README.md | 64 +++++++++++++++++++++++++++++++---------- demo.js | 42 +++++++++++++++++++++++++++ package.json | 4 ++- populatedb.js | 79 +++++++++++++++++++++++++++------------------------ 4 files changed, 136 insertions(+), 53 deletions(-) create mode 100644 demo.js diff --git a/README.md b/README.md index 9fbb3e67..3334d68a 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,81 @@ # express-locallibrary-tutorial -Tutorial "Local Library" website written in in Node/Express. +Tutorial "Local Library" website written in Node/Express. --- This web application creates an online catalog for a small local library, where users can browse available books and manage their accounts. -![A UML diagram showing the relation of database entities in this example repository](https://raw.githubusercontent.com/mdn/express-locallibrary-tutorial/main/public/images/Library%20Website%20-%20Mongoose_Express.png) +![A UML diagram showing the relation of database entities in this example repository](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs/mongoose/library_website_-_mongoose_express.png) -For more information see the associated [MDN tutorial home page](https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Tutorial_local_library_website). +For more information see the associated [MDN tutorial home page](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs/Tutorial_local_library_website). > **Note** The [auth branch](/../../tree/auth) in this repository implements an _unsupported_ and _undocumented_ version of the library with User Authentication and Authorization. This may be a useful starting point for some users. +## Try it without a database + +If you just want to see the finished site, you don't need to set up MongoDB. +Install [Node.js](https://nodejs.org/en/download) 24 or later, clone this repo, and run these commands in its root: + +```bash +npm install +npm run demo +``` + +Then open . +The demo starts a temporary in-memory database and fills it with sample books, authors, genres and book copies. +Any changes you make are lost when you stop the server with Ctrl+C. +The first run downloads a MongoDB binary, so it may take a minute. + ## Quick Start -To get this project up and running locally on your computer: +To set the project up for development, with a database that keeps your data: + +1. Set up a [Node.js](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs/development_environment) development environment (Node.js 24 or later). +2. Make a MongoDB database available. + By default the app connects to a local MongoDB server at `mongodb://127.0.0.1:27017/local_library`. + You can: + - [Install MongoDB Community Edition](https://www.mongodb.com/docs/manual/administration/install-community/) locally. + - Run MongoDB in [Docker](https://docs.docker.com/get-started/get-docker/), keeping the data in a named volume: -1. Set up a [Node.js](https://wiki.developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/development_environment) development environment. -2. Once you have node setup install the project in the root of your clone of this repo: + ```bash + docker run -d --name locallibrary-mongo -p 127.0.0.1:27017:27017 -v locallibrary-data:/data/db mongo:8 + ``` + + - Use a hosted database such as [MongoDB Atlas](https://www.mongodb.com/products/platform/atlas-database), and set the `MONGODB_URI` environment variable to its connection string. +3. Once you have node setup install the project in the root of your clone of this repo: ```bash npm install ``` -3. Run the tutorial server, using the appropriate command line shell for your environment: +4. Optionally, add some sample books, authors, genres and book copies to the database: + + ```bash + node populatedb.js "mongodb://127.0.0.1:27017/local_library" + ``` + +5. Run the tutorial server, using the appropriate command line shell for your environment: ```bash - # Linux terminal + # Linux or macOS terminal DEBUG=express-locallibrary-tutorial:* npm run devstart - # Windows Powershell - $ENV:DEBUG = "express-locallibrary-tutorial:*"; npm start + # Windows CMD + SET DEBUG=express-locallibrary-tutorial:* & npm run devstart + + # Windows PowerShell + $ENV:DEBUG = "express-locallibrary-tutorial:*"; npm run devstart ``` -4. Open a browser to to open the library site. + The `devstart` script restarts the server when you change a JavaScript file. + Use `npm start` instead to run the server without watching for changes. -> [!NOTE] -> The library uses a default MongoDB database hosted on [MongoDB Atlas](https://www.mongodb.com/cloud/atlas). -> You should use a different database for your own code experiments. +6. Open a browser to to open the library site. ## Contributing -The project is the result of carefully running through all the steps in the [tutorial on MDN](https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Tutorial_local_library_website). +The project is the result of carefully running through all the steps in the [tutorial on MDN](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs/Tutorial_local_library_website). Any changes to either MDN or this project must be synchronized. Generally it is better to implement changes here before submitting them to MDN. diff --git a/demo.js b/demo.js new file mode 100644 index 00000000..8e139373 --- /dev/null +++ b/demo.js @@ -0,0 +1,42 @@ +// Run the LocalLibrary with a temporary in-memory database that is filled with sample data. +// No MongoDB installation is needed. All data is discarded when the server stops. +// Usage: npm run demo + +import { spawn } from "node:child_process"; +import { once } from "node:events"; +import path from "node:path"; +import { MongoMemoryServer } from "mongodb-memory-server"; +import mongoose from "mongoose"; + +console.log("Starting in-memory MongoDB (the first run downloads MongoDB)..."); +const mongoServer = await MongoMemoryServer.create(); +const mongoDB = mongoServer.getUri("local_library"); + +async function shutdown() { + await mongoose.disconnect(); + await mongoServer.stop(); + process.exit(); +} +process.once("SIGINT", shutdown); +process.once("SIGTERM", shutdown); + +// Add the sample data by running populatedb.js against the in-memory database. +const populate = spawn( + process.execPath, + [path.join(import.meta.dirname, "populatedb.js"), mongoDB], + { stdio: "inherit" }, +); +const [exitCode] = await once(populate, "exit"); +if (exitCode !== 0) { + await mongoServer.stop(); + throw new Error(`populatedb.js failed with exit code ${exitCode}`); +} + +// Start the app. server.js reads the database URL from MONGODB_URI. +process.env.MONGODB_URI = mongoDB; +await import("./server.js"); + +const port = process.env.PORT ?? 3000; +console.log(` +LocalLibrary demo running at http://localhost:${port}/ +The database is in memory: your changes are lost when you stop the server (Ctrl+C).`); diff --git a/package.json b/package.json index f552ce15..d560838d 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,9 @@ "version": "1.0.0", "scripts": { "start": "node server.js", - "devstart": "node --watch server.js" + "devstart": "node --watch server.js", + "demo": "node demo.js", + "test": "node --test" }, "type": "module", "private": true, diff --git a/populatedb.js b/populatedb.js index 7cad9ede..3e7e7568 100644 --- a/populatedb.js +++ b/populatedb.js @@ -1,4 +1,3 @@ -import createDebug from "debug"; import mongoose from "mongoose"; import Book from "./models/book.js"; @@ -6,33 +5,39 @@ import Author from "./models/author.js"; import Genre from "./models/genre.js"; import BookInstance from "./models/bookinstance.js"; -const debug = createDebug("express-locallibrary-tutorial:populatedb"); +// Get the database URL passed on the command line +const mongoDB = process.argv[2]; -debug( - 'This script populates some test books, authors, genres and bookinstances to your database. Specified database as argument - e.g.: node populatedb "mongodb+srv://cooluser:coolpassword@cluster0.cojoign.mongodb.net/local_library?retryWrites=true&w=majority&appName=Cluster0"' -); +if (!mongoDB) { + console.error( + 'Usage: node populatedb.js ""\n' + + 'For example: node populatedb.js "mongodb://127.0.0.1:27017/local_library"', + ); + process.exit(1); +} -// Get arguments passed on command line -const userArgs = process.argv.slice(2); +console.log( + "This script populates some test books, authors, genres and bookinstances to your database.", +); const genres = []; const authors = []; const books = []; const bookinstances = []; -const mongoDB = userArgs[0]; - -main().catch((err) => debug(err)); - -async function main() { - debug("Debug: About to connect"); +try { + console.log("Debug: About to connect"); await mongoose.connect(mongoDB); - debug("Debug: Should be connected?"); + console.log("Debug: Should be connected?"); await createGenres(); await createAuthors(); await createBooks(); await createBookInstances(); - debug("Debug: Closing mongoose"); +} catch (err) { + console.error("Failed to populate the database:", err); + process.exitCode = 1; +} finally { + console.log("Debug: Closing mongoose"); await mongoose.connection.close(); } @@ -43,7 +48,7 @@ async function genreCreate(index, name) { const genre = new Genre({ name: name }); await genre.save(); genres[index] = genre; - debug(`Added genre: ${name}`); + console.log(`Added genre: ${name}`); } async function authorCreate(index, first_name, family_name, d_birth, d_death) { @@ -55,7 +60,7 @@ async function authorCreate(index, first_name, family_name, d_birth, d_death) { await author.save(); authors[index] = author; - debug(`Added author: ${first_name} ${family_name}`); + console.log(`Added author: ${first_name} ${family_name}`); } async function bookCreate(index, title, summary, isbn, author, genre) { @@ -70,7 +75,7 @@ async function bookCreate(index, title, summary, isbn, author, genre) { const book = new Book(bookdetail); await book.save(); books[index] = book; - debug(`Added book: ${title}`); + console.log(`Added book: ${title}`); } async function bookInstanceCreate(index, book, imprint, due_back, status) { @@ -84,11 +89,11 @@ async function bookInstanceCreate(index, book, imprint, due_back, status) { const bookinstance = new BookInstance(bookinstancedetail); await bookinstance.save(); bookinstances[index] = bookinstance; - debug(`Added bookinstance: ${imprint}`); + console.log(`Added bookinstance: ${imprint}`); } async function createGenres() { - debug("Adding genres"); + console.log("Adding genres"); await Promise.all([ genreCreate(0, "Fantasy"), genreCreate(1, "Science Fiction"), @@ -97,7 +102,7 @@ async function createGenres() { } async function createAuthors() { - debug("Adding authors"); + console.log("Adding authors"); await Promise.all([ authorCreate(0, "Patrick", "Rothfuss", "1973-06-06", false), authorCreate(1, "Ben", "Bova", "1932-11-8", false), @@ -108,7 +113,7 @@ async function createAuthors() { } async function createBooks() { - debug("Adding Books"); + console.log("Adding Books"); await Promise.all([ bookCreate( 0, @@ -116,7 +121,7 @@ async function createBooks() { "I have stolen princesses back from sleeping barrow kings. I burned down the town of Trebon. I have spent the night with Felurian and left with both my sanity and my life. I was expelled from the University at a younger age than most people are allowed in. I tread paths by moonlight that others fear to speak of during day. I have talked to Gods, loved women, and written songs that make the minstrels weep.", "9781473211896", authors[0], - [genres[0]] + [genres[0]], ), bookCreate( 1, @@ -124,7 +129,7 @@ async function createBooks() { "Picking up the tale of Kvothe Kingkiller once again, we follow him into exile, into political intrigue, courtship, adventure, love and magic... and further along the path that has turned Kvothe, the mightiest magician of his age, a legend in his own time, into Kote, the unassuming pub landlord.", "9788401352836", authors[0], - [genres[0]] + [genres[0]], ), bookCreate( 2, @@ -132,7 +137,7 @@ async function createBooks() { "Deep below the University, there is a dark place. Few people know of it: a broken web of ancient passageways and abandoned rooms. A young woman lives there, tucked among the sprawling tunnels of the Underthing, snug in the heart of this forgotten place.", "9780756411336", authors[0], - [genres[0]] + [genres[0]], ), bookCreate( 3, @@ -140,7 +145,7 @@ async function createBooks() { "Humankind headed out to the stars not for conquest, nor exploration, nor even for curiosity. Humans went to the stars in a desperate crusade to save intelligent life wherever they found it. A wave of death is spreading through the Milky Way galaxy, an expanding sphere of lethal gamma ...", "9780765379528", authors[1], - [genres[1]] + [genres[1]], ), bookCreate( 4, @@ -148,7 +153,7 @@ async function createBooks() { "In Ben Bova's previous novel New Earth, Jordan Kell led the first human mission beyond the solar system. They discovered the ruins of an ancient alien civilization. But one alien AI survived, and it revealed to Jordan Kell that an explosion in the black hole at the heart of the Milky Way galaxy has created a wave of deadly radiation, expanding out from the core toward Earth. Unless the human race acts to save itself, all life on Earth will be wiped out...", "9780765379504", authors[1], - [genres[1]] + [genres[1]], ), bookCreate( 5, @@ -156,7 +161,7 @@ async function createBooks() { "Summary of test book 1", "ISBN111111", authors[4], - [genres[0], genres[1]] + [genres[0], genres[1]], ), bookCreate( 6, @@ -164,20 +169,20 @@ async function createBooks() { "Summary of test book 2", "ISBN222222", authors[4], - false + false, ), ]); } async function createBookInstances() { - debug("Adding authors"); + console.log("Adding book instances"); await Promise.all([ bookInstanceCreate( 0, books[0], "London Gollancz, 2014.", false, - "Available" + "Available", ), bookInstanceCreate(1, books[1], " Gollancz, 2011.", false, "Loaned"), bookInstanceCreate(2, books[2], " Gollancz, 2015.", false, false), @@ -186,42 +191,42 @@ async function createBookInstances() { books[3], "New York Tom Doherty Associates, 2016.", false, - "Available" + "Available", ), bookInstanceCreate( 4, books[3], "New York Tom Doherty Associates, 2016.", false, - "Available" + "Available", ), bookInstanceCreate( 5, books[3], "New York Tom Doherty Associates, 2016.", false, - "Available" + "Available", ), bookInstanceCreate( 6, books[4], "New York, NY Tom Doherty Associates, LLC, 2015.", false, - "Available" + "Available", ), bookInstanceCreate( 7, books[4], "New York, NY Tom Doherty Associates, LLC, 2015.", false, - "Maintenance" + "Maintenance", ), bookInstanceCreate( 8, books[4], "New York, NY Tom Doherty Associates, LLC, 2015.", false, - "Loaned" + "Loaned", ), bookInstanceCreate(9, books[0], "Imprint XXX2", false, false), bookInstanceCreate(10, books[1], "Imprint XXX3", false, false), From 069fb171be4a3887f28dee97a79e56127b0dd6ac Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Tue, 10 Nov 2026 11:30:30 +1100 Subject: [PATCH 3/4] Fix date time zone, author delete id and book update redirect - Format dates in UTC so they display as entered in every time zone (they were a day early west of UTC, and disagreed with the edit form). - authorDeletePost deletes the author in the URL (req.params.id) rather than an id from the form body, so a forged request can't delete a different author who still has books. Remove the unused hidden field and add a regression test. - bookUpdatePost redirects to book.url, so it doesn't crash if the book was deleted while the form was open. - Restore the guide's lowercase "Delete author"/"Update author" and genre link text. Co-Authored-By: Claude Opus 5.5 --- controllers/authorController.js | 2 +- controllers/bookController.js | 4 ++-- models/author.js | 1 + models/bookinstance.js | 1 + test/routes/author.test.mjs | 31 +++++++++++++++++++++++++++---- views/author_delete.pug | 3 --- views/author_detail.pug | 4 ++-- views/genre_detail.pug | 4 ++-- 8 files changed, 36 insertions(+), 14 deletions(-) diff --git a/controllers/authorController.js b/controllers/authorController.js index 225c4eb4..9dba2603 100644 --- a/controllers/authorController.js +++ b/controllers/authorController.js @@ -137,7 +137,7 @@ export const authorDeletePost = async (req, res, next) => { return; } // Author has no books. Delete object and redirect to the list of authors. - await Author.findByIdAndDelete(req.body.authorid); + await Author.findByIdAndDelete(req.params.id); res.redirect("/catalog/authors"); }; diff --git a/controllers/bookController.js b/controllers/bookController.js index 06da786d..3a7435ab 100644 --- a/controllers/bookController.js +++ b/controllers/bookController.js @@ -297,8 +297,8 @@ export const bookUpdatePost = [ } // Data from form is valid. Update the record. - const updatedBook = await Book.findByIdAndUpdate(req.params.id, book, {}); + await Book.findByIdAndUpdate(req.params.id, book, {}); // Redirect to book detail page. - res.redirect(updatedBook.url); + res.redirect(book.url); }, ]; diff --git a/models/author.js b/models/author.js index 61a669e6..68d275fe 100644 --- a/models/author.js +++ b/models/author.js @@ -31,6 +31,7 @@ const dateFormatter = new Intl.DateTimeFormat("en-US", { year: "numeric", month: "short", day: "numeric", + timeZone: "UTC", }); AuthorSchema.virtual("lifespan").get(function () { diff --git a/models/bookinstance.js b/models/bookinstance.js index 98765b9e..a0cae88c 100644 --- a/models/bookinstance.js +++ b/models/bookinstance.js @@ -24,6 +24,7 @@ const dateFormatter = new Intl.DateTimeFormat("en-US", { year: "numeric", month: "short", day: "numeric", + timeZone: "UTC", }); BookInstanceSchema.virtual("due_back_formatted").get(function () { diff --git a/test/routes/author.test.mjs b/test/routes/author.test.mjs index cf02ebb5..729d9755 100644 --- a/test/routes/author.test.mjs +++ b/test/routes/author.test.mjs @@ -116,8 +116,6 @@ test("Author Routes", async (t) => { async () => { const res = await request(app) .post(`/catalog/author/${author._id}/delete`) - .type("form") - .send({ authorid: author._id.toString() }) // Form body .expect(302); assert.strictEqual( @@ -148,8 +146,6 @@ test("Author Routes", async (t) => { const res = await request(app) .post(`/catalog/author/${author._id}/delete`) - .type("form") - .send({ id: author._id.toString() }) // Note: Was `id`, but controller likely expects `authorid` for consistency .expect(200); // Should NOT redirect const found = await Author.findById(author._id); @@ -168,6 +164,33 @@ test("Author Routes", async (t) => { `Expected "Bound to Author", got: ${res.text}` ); }); + + await t.test( + "should only delete the author in the URL, not an id in the form body", + async () => { + const genre = await Genre.create({ name: "Drama" }); + await Book.create({ + title: "Bound to Author", + author: author._id, + summary: "A book written by the author", + isbn: "1111111111", + genre: [genre._id], + }); + const other = await Author.create({ + first_name: "Other", + family_name: "Author", + }); + + await request(app) + .post(`/catalog/author/${author._id}/delete`) + .type("form") + .send({ authorid: other._id.toString() }) + .expect(200); // URL author has books, so nothing is deleted + + assert.notStrictEqual(await Author.findById(author._id), null); + assert.notStrictEqual(await Author.findById(other._id), null); + } + ); }); // Author Create Routes Suite diff --git a/views/author_delete.pug b/views/author_delete.pug index 62cdb06a..7fc20f67 100644 --- a/views/author_delete.pug +++ b/views/author_delete.pug @@ -20,7 +20,4 @@ block content p Do you really want to delete this Author? form(method='POST') - div.form-group - input#authorid.form-control(type='hidden', name='authorid', value=author._id ) - button.btn.btn-primary(type='submit') Delete diff --git a/views/author_detail.pug b/views/author_detail.pug index a9b17078..aba01ec8 100644 --- a/views/author_detail.pug +++ b/views/author_detail.pug @@ -19,6 +19,6 @@ block content hr p - a(href=author.url+'/delete') Delete Author + a(href=author.url+'/delete') Delete author p - a(href=author.url+'/update') Update Author + a(href=author.url+'/update') Update author diff --git a/views/genre_detail.pug b/views/genre_detail.pug index 0c049cd2..6757e6ab 100644 --- a/views/genre_detail.pug +++ b/views/genre_detail.pug @@ -18,6 +18,6 @@ block content hr p - a(href=genre.url+'/delete') Delete Genre + a(href=genre.url+'/delete') Delete genre p - a(href=genre.url+'/update') Update Genre + a(href=genre.url+'/update') Update genre From e12ddfbcb6e651e5964d7b86ae330aa7f2d74d91 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Tue, 10 Nov 2026 16:00:30 +1100 Subject: [PATCH 4/4] Use an ISO 8601 date for Ben Bova's birth date "1932-11-8" isn't a valid ISO date string, so it was parsed as local midnight. With UTC date formatting, it displayed as Nov 7 on machines east of UTC. Co-Authored-By: Claude Opus 5.5 --- populatedb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/populatedb.js b/populatedb.js index 3e7e7568..499caaaa 100644 --- a/populatedb.js +++ b/populatedb.js @@ -105,7 +105,7 @@ async function createAuthors() { console.log("Adding authors"); await Promise.all([ authorCreate(0, "Patrick", "Rothfuss", "1973-06-06", false), - authorCreate(1, "Ben", "Bova", "1932-11-8", false), + authorCreate(1, "Ben", "Bova", "1932-11-08", false), authorCreate(2, "Isaac", "Asimov", "1920-01-02", "1992-04-06"), authorCreate(3, "Bob", "Billings", false, false), authorCreate(4, "Jim", "Jones", "1971-12-16", false),