also probably better if we move these handlers to their own file, like errorhandling.js, required separately from the middleware.js file