Added promises to middleware api