Sandeep Chikhale
Sandeep Chikhale

Reputation: 1515

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

I am a total newb when comes to server side programming. I have created and rest api on local machine using

  1. NodeJS
  2. Express
  3. Mongoose
  4. MongDB database created in mLAB.

So, can any body please provide me any document, guideline tutorial - I have tried reading other but not able to find any tutorial for this combination.

Please don't provide negative comment on this _ i know question might not be excellent but I am not able to find the correct way/approach to solve this problem.

Upvotes: 2

Views: 862

Answers (1)

KarlR
KarlR

Reputation: 1615

Since You use alomst MEAN stack (Mongo, Express, Node - You lack only Angular) check that paragraph: project&deploy. You can go with few approaches but I will describe one using Heroku CLI:

  • sign in to heroku: heroku login
  • via heroku cli create new application: heroku create,
  • provision mongodb: heroku addons:create mongolab
  • create application: server, routes etc.
  • stage: git add .
  • commit changes: git commit -m 'test app'
  • push them to heroku: git push heroku master

Please remember that:

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.

Once You are done with the work, You can go to site where the app is hosted by typing: heroku open

Upvotes: 1

Related Questions