const express = require("express"); const auth = require("../middleware/auth"); const { asyncHandler } = require("../middleware/errorHandler"); const { getCacheStats, clearCache } = require("../middleware/cache"); const router = express.Router(); /** * GET /api/cache/stats * Get cache statistics * @access Private (authenticated users) */ router.get( "/stats", auth, asyncHandler(async (req, res) => { const stats = getCacheStats(); res.json({ status: "operational", ...stats, timestamp: new Date().toISOString() }); }) ); /** * DELETE /api/cache * Clear all cache * @access Private (authenticated users - in production should be admin only) */ router.delete( "/", auth, asyncHandler(async (req, res) => { clearCache(); res.json({ msg: "Cache cleared successfully", timestamp: new Date().toISOString() }); }) ); module.exports = router;