Transform the output stream of connect using middleware