middleware.js defines all: instead of finally: