add video backend server, fix styling and more #54
+1
-1
@@ -9,6 +9,6 @@ const movieSchema = new mongoose.Schema({
|
|||||||
category: { type: String, required: true },
|
category: { type: String, required: true },
|
||||||
vod_link: { type: String, required: true },
|
vod_link: { type: String, required: true },
|
||||||
watchedBy: [{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }]
|
watchedBy: [{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }]
|
||||||
});
|
}, { timestamps: true });
|
||||||
|
|
||||||
module.exports = mongoose.model("Movie", movieSchema);
|
module.exports = mongoose.model("Movie", movieSchema);
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
<!-- Displaying last updated vod_links -->
|
<!-- Displaying last updated vod_links -->
|
||||||
<div class="alert alert-warning fade show" role="alert">
|
<div class="alert alert-warning fade show" role="alert">
|
||||||
Dernière mise à jour des films: <strong>—</strong>
|
Dernière mise à jour des films: <strong id="movies-last-updated">—</strong>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Displaying the ratio of watched movies -->
|
<!-- Displaying the ratio of watched movies -->
|
||||||
|
|||||||
@@ -38,6 +38,33 @@ router.get("/", async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get latest movie update/add timestamp
|
||||||
|
router.get("/last-update", async (req, res) => {
|
||||||
|
const token = req.headers.authorization?.split(" ")[1];
|
||||||
|
if (!token) return res.status(401).json({ message: "Token is required" });
|
||||||
|
|
||||||
|
try {
|
||||||
|
jwt.verify(token, process.env.JWT_SECRET);
|
||||||
|
|
||||||
|
const latestMovie = await Movie.findOne().sort({ updatedAt: -1, createdAt: -1, _id: -1 });
|
||||||
|
if (!latestMovie) {
|
||||||
|
return res.status(200).json({ lastUpdated: null });
|
||||||
|
}
|
||||||
|
|
||||||
|
const lastUpdated =
|
||||||
|
latestMovie.updatedAt ||
|
||||||
|
latestMovie.createdAt ||
|
||||||
|
(typeof latestMovie._id?.getTimestamp === "function" ? latestMovie._id.getTimestamp() : null);
|
||||||
|
|
||||||
|
return res.status(200).json({ lastUpdated: lastUpdated ? new Date(lastUpdated).toISOString() : null });
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof jwt.JsonWebTokenError) {
|
||||||
|
return res.status(401).json({ message: "Invalid or expired token" });
|
||||||
|
}
|
||||||
|
return res.status(500).json({ error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Get watched movies for the user
|
// Get watched movies for the user
|
||||||
router.get("/watchedMovies", async (req, res) => {
|
router.get("/watchedMovies", async (req, res) => {
|
||||||
const token = req.headers.authorization?.split(" ")[1]; // Get token from header
|
const token = req.headers.authorization?.split(" ")[1]; // Get token from header
|
||||||
|
|||||||
Reference in New Issue
Block a user