Permalink
Browse files

Merge pull request #111 from ga-wdi-boston/029/master

029/master
  • Loading branch information...
caleb-pearce committed Feb 11, 2019
2 parents 7ac1bd8 + 48da7e9 commit 16cde0cb7181d48f357c95970e714f7aef48947c
Showing with 34 additions and 21 deletions.
  1. +34 −21 README.md
@@ -24,24 +24,28 @@ Begin inside the root directory of your application (the directory you
just renamed to `express-upload-api` from `express-api-template`) deploy a new
application to Heroku:

- [ ] Run `heroku create` in the command line in the root of your Express API to create a new (blank) app on Heroku.
- [ ] Run `heroku create` in the command line in the root of your Express API to
create a new (blank) app on Heroku.
- [ ] commit to your local master branch
- [ ] Push your latest code to Heroku (`git push heroku master`)
- [ ] Add any addons `e.g. mlab to create a deployed database`
- [ ] [mlab add on steps](https://git.generalassemb.ly/ga-wdi-boston/express-api-deployment-guide#creating-mlab-addon)
- [ ] in terminal, run : `git push heroku master` (should build your site)
- [ ] due to the first line of code in the `server.js` file, the default deployment environment will be `production`
- [ ] in terminal, run :
```
echo SECRET_KEY=$(openssl rand -base64 66 | tr -d '\n')
```
this should generate a secret_key
- [ ] in the terminal run: `heroku config:set SECRET_KEY=<copy and paste secret_key generated from last command>` . It should start with “SECRET_KEY= and a span of about 40 randomized characters”
- [ ] you need to set your CLIENT_ORIGIN so that your deployed API will ONLY accept requests from the correct domain. IF you're client is deployed on Github, your ORIGIN will be:
- [ ] Add any addons
- [ ] If using MongoDB you'll need to follow the [mlab add on steps](https://git.generalassemb.ly/ga-wdi-boston/express-api-deployment-guide#creating-mlab-addon)
- [ ] in terminal, run: `git push heroku master` (should build your site)
- [ ] due to the first line of code in the `server.js` file, the default
deployment environment will be `production`
- [ ] in terminal, run: `echo SECRET_KEY=$(openssl rand -base64 66 | tr -d '\n')`
this should generate a secret_key
- [ ] in the terminal run:
`heroku config:set SECRET_KEY=<copy and paste secret_key generated from last command>`.
It should start with “SECRET_KEY= and a span of about 40 randomized characters”
- [ ] you need to set your CLIENT_ORIGIN so that your deployed API will ONLY
accept requests from the correct domain. IF you're client is deployed on Github,
your ORIGIN will be:
`https://<% github username %>.github.io`
- [ ] Set your client ORIGIN by:
`heroku config:set CLIENT_ORIGIN="https://<% github username %>.github.io"`
- [ ] You should have three config variables set in heroku (`heroku>settings>config vars`): MONGODB_URI, SECRET_KEY, CLIENT_ORIGIN
- [ ] You should have three config variables set in heroku
(`heroku>settings>config vars`): MONGODB_URI, SECRET_KEY, CLIENT_ORIGIN
- [ ] Once all three of these are set, run in terminal: `heroku restart`
- [ ] Then in terminal, run: `heroku open`

@@ -50,12 +54,12 @@ A full list of Heroku commands can be accessed by running `heroku --help`
### Share Your App **(REQUIRED)**

1. Open an issue on this repository [here](https://git.generalassemb.ly/ga-wdi-boston/express-api-deployment-guide/issues/new).

1. Include the deployed URL of your heroku app in the description.

## Creating Mlab addon

- [ ] Run heroku addons:create with mongolab:sandbox `$ heroku addons:create mongolab:sandbox`
- [ ] Run heroku addons:create with mongolab:sandbox
`$ heroku addons:create mongolab:sandbox`

The first time you run the above command you'll see a message like this:

@@ -64,26 +68,32 @@ Creating mongolab:sandbox on ⬢ pacific-cliffs-91276... !
▸ Please verify your account to install this add-on plan (please enter a credit card) For more information, see
▸ https://devcenter.heroku.com/categories/billing Verify now at https://heroku.com/verify
```
- [ ] You need to go to that URL, enter in your credit card information and then re-run the command again. This time you should see something like:

- [ ] You need to go to that URL, enter in your credit card information and then
re-run the command again. This time you should see something like:

```
~/wdi/projects/group-project/TimeCapsule-Backend (master)$ heroku addons:create mongolab:sandbox
Creating mongolab:sandbox on ⬢ pacific-cliffs-91276... free
Welcome to mLab. Your new subscription is being created and will be available shortly. Please consult the mLab Add-on Admin UI to check on its progress.
Welcome to mLab. Your new subscription is being created and will be available
shortly. Please consult the mLab Add-on Admin UI to check on its progress.
Created mongolab-cubed-11237 as MONGODB_URI
Use heroku addons:docs mongolab to view documentation
```

Now you can log into your heroku dashboard, go to add-ons and click the mlab link. This will bring you to your mlab database.
Now you can log into your heroku dashboard, go to add-ons and click the mlab
link. This will bring you to your mlab database.

**If you already have an mLab account linked to your heroku account:**

If you already have an mLab account connected to your heroku account, you may see something more like this:
If you already have an mLab account connected to your heroku account, you may
see something more like this:

```sh
〉 heroku addons:create mongolab:sandbox
Creating mongolab:sandbox on ⬢ sleepy-dawn-72120... free
Welcome to mLab. Your new subscription is being created and will be available shortly. Please consult the mLab Add-on Admin UI to check on its progress.
Welcome to mLab. Your new subscription is being created and will be available
shortly. Please consult the mLab Add-on Admin UI to check on its progress.
Created mongolab-tetrahedral-59408 as MONGODB_URI
Use heroku addons:docs mongolab to view documentation
~/wdi-root/forge/wip/express-deploy-me  master
@@ -115,9 +125,12 @@ S3](https://aws.amazon.com/s3/).

## Troubleshooting

- **First step upon encountering an issue should be to run `heroku logs` to read the logs of your deployed heroku server**
- **First step upon encountering an issue should be to run `heroku logs` to
read the logs of your deployed heroku server**
- [Heroku Addons](https://devcenter.heroku.com/articles/managing-add-ons) and [mLab MongoDB](https://elements.heroku.com/addons/mongolab)
- [Previous Issues](https://git.generalassemb.ly/ga-wdi-boston/team-project/issues?utf8=%E2%9C%93&q=is%3Aissue%20deploy%2C%20heroku)
- If you are getting a CORS error and the `CLIENT_ORIGIN` is correct, ensure the
`MONGODB_URI` is set successfully with the value that [mLab add-on](https://devcenter.heroku.com/articles/mongolab) provides.

## Additional Resources

0 comments on commit 16cde0c

Please sign in to comment.