* 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
18 lines
431 B
JavaScript
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 };
|