tududi/backend/middleware/permissionCache.js
Chris 6fb87ac80a
Feat refactor tasks pt1 (#536)
* Refactor swagger docs

* Scaffold refactor

* Refactor crud tasks

* fixup! Refactor crud tasks

* Break down task layout

* fixup! Break down task layout

* fixup! fixup! Break down task layout

* Cleanup comments

* fixup! Cleanup comments

* Cleanup obsolete code

* Remove helpers
2025-11-15 14:02:06 +02:00

18 lines
431 B
JavaScript

/**
* Request-scoped permission cache middleware
* Caches permission lookups for the duration of a single request
*/
const permissionCache = (req, res, next) => {
// Create a cache object scoped to this request
req.permissionCache = new Map();
// Clean up cache after response is sent
res.on('finish', () => {
req.permissionCache.clear();
});
next();
};
module.exports = { permissionCache };