如何在 heroku 或 amazon 网络服务上部署我的 rest api?

How to deploy my rest api on heroku or amazon web services?

在服务器端编程方面,我完全是个新手。 我已经使用

在本地机器上创建和休息 api
  1. NodeJS
  2. 快递
  3. 猫鼬
  4. 在 mLAB 中创建的 MongDB 数据库。

所以,任何人都可以向我提供任何文件、指南教程 - 我已经尝试阅读其他但无法找到该组合的任何教程。

请不要对此提供负面评论_我知道问题可能不是很好,但我找不到正确的 way/approach 来解决这个问题。

由于您使用了 alomst MEAN 堆栈(Mongo、Express、Node - 您只缺少 Angular)检查该段落:project&deploy. You can go with few approaches but I will describe one using Heroku CLI:

  • 登录 heroku:heroku login
  • 通过 heroku cli 创建新应用程序:heroku create,
  • 规定mongodb:heroku addons:create mongolab
  • 创建应用程序:服务器、路由等
  • 阶段:git add .
  • 提交更改:git commit -m 'test app'
  • 将它们推送到 heroku:git push heroku master

请记住:

When you create a mLab add-on, the database connection URI is stored as a config var. Heroku config variables are equivalent to an environment variable, which you can use in development and your local environment. You can access this variable in your Node.js code as process.env.MONGODB_URI, which we will use later in our server code.

完成工作后,您可以通过键入以下内容转到托管该应用程序的站点: heroku open