a connect middleware that runs a provided function if a request last longer than a given duration