Hello I have express app where i need to plug a custom middleware/logic before accessing static folder for serving files, how i can achieve that without applying this middleware on every route. For now code looks like:
function middleware() {
console.log('hello');
}
app.use(middleware).use(express.static('public'));
app.listen(8000, () => {
console.log('server running on 8000');
});
app.get('/hi', (req, res) => {});
Issue is when hi is called middleware is executed as well and I want to execute it only if static files from public folder are called