How to move cloud code from parse.com to heroku

扶醉桌前 提交于 2019-12-04 13:28:44

Migrating cloud code can range in difficulty depending on how involved that code is. Here's a workflow for validating your code:

1) Check that you can build your Heroku app locally with the right Node version.

2) Comment out all of your cloud code. You want to start introducing your code in parts and make sure it compiles with each re-introduced function.

3) Install the node modules for each service that you use. If you use stripe/mailgun or any other package, add them in your package.json file and run npm install. Then include them in your main.js file with the require('packageName').

4) The cloud server uses Express.js version 4.2 and a Parse.com runs Express version 2.0 or 3.0 but not 4.0. If you use any middlewear then you need to change it to the proper Express 4.0 syntax/methodology.

5) There is no support for cloud jobs so rename all your *.job functions to *.define and comment properly so you can come back to them later. If you did not use cloud jobs then don't worry.

6) If you did use cloud jobs, now you need to setup a heroku worker/scheduler to run those old *.job (now *.define) calls at the proper time intervals you had.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!