Maintainable asynchronous JavaScript with promises