Use app.middleware() register middleware into various phases