feat: Add compression and caching to movie routes

Adds gzip compression middleware and an in-memory cache for movie data to improve performance. Also adds database indexes for common query patterns.

Co-authored-by: mathieumoran1 <[email protected]>
This commit is contained in:
Cursor Agent
2025-12-21 21:24:27 +00:00
co-authored by mathieumoran1
parent 1e7ab962d6
commit 3884ce6492
7 changed files with 165 additions and 30 deletions
+7
View File
@@ -20,4 +20,11 @@ const movieSchema = new mongoose.Schema({
watchedBy: [{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }]
}, { timestamps: true });
// Common read patterns:
// - list movies for a year, sorted by title
// - check "last update" per year (sort by updatedAt)
movieSchema.index({ year: 1, title: 1 });
movieSchema.index({ year: 1, updatedAt: -1 });
movieSchema.index({ year: 1, imdb_id: 1 });
module.exports = mongoose.model("Movie", movieSchema);