Heroku

I decide to post the Mongo Explorer API project to Heroku.

Here is what had to do:

  1. Create an account on Heroku
  2. Installed Heroku Command Line Interface (CLI) with homebrew:
     brew install Heroku
  3. Logger on to Heroku:
     heroku login
  4. Created an app:
    heroku create
  5. Deploy the code:
    git push heroku master
  6. Obviously, the app crashed and did not run, so I had to check the logs:
    heroku logs --tail

It took me couple hours to figure out how to prepare my project to run on Heroku:

  1. I had to add start script in package.json. Heroku uses Procfile, but if file is not found then it looks for start script:
    “scripts”: {
    “start”: “node app.js”
    }
  2. Heroku assigns port dynamically, so I had to change startup code from: app.listen(config.get(‘NODE_PORT’));
    to
    var port = process.env.PORT || config.get('NODE_PORT');
    app.listen(port);
  3. Now the app started, but Swagger UI was failing so I had do the last change: in swaggerDefinition variable I had to change
    host from localhost:4000 to dry-spire-23794.herokuapp.com
  4. The last thing was adding CORS support.

And now my app runs on:

https://dry-spire-23794.herokuapp.com/