mks-greenfield / trendr

"don't create trends, follow them"
2 stars 5 forks source link

[feat] Add Node Foreman to track env variables #21

Closed polinabythebay closed 8 years ago

polinabythebay commented 8 years ago

Let's use Node Foreman to keep track of our environment variables! :balloon: :balloon: :crystal_ball:

A few notes:

For example, since our project currently uses:

var consumer_key = process.env.CONSUMER_KEY;
var consumer_secret = process.env.CONSUMER_SECRET;
var access_token_key = process.env.ACCESS_TOKEN_KEY;
var access_token_secret = process.env.ACCESS_TOKEN_SECRET;

In your .env file you want to have the following:

CONSUMER_KEY='asdfjlaksdfj'
CONSUMER_SECRET='aslkdfjalskdjf'
ACCESS_TOKEN_KEY='alskdfjalskdjf'
ACCESS_TOKEN_SECRET='asldkfjalksdjf'

Node Foreman needs configuration in both Procfile and package.json to load vars. Since our Procfile specifies nodemon make sure you have nodemon installed locally. Our package.json is set to run nf start when you run node start, so to start the server/load the vars simply do:

$ npm start

> trendr@1.0.0 start /Users/psoshnin/Desktop/makersquare/greenfield/trendr-PERSONAL/trendr
> nf start

[OKAY] Loaded ENV .env File as KEY=VALUE Format
[OKAY] Trimming display Output to 96 Columns
3:22:02 PM web.1 |  [nodemon] 1.8.1
3:22:02 PM web.1 |  [nodemon] to restart at any time, enter `rs`
3:22:02 PM web.1 |  [nodemon] watching: *.*
3:22:02 PM web.1 |  [nodemon] starting `node app.js`
3:22:02 PM web.1 |  Listening on: 5000

Make sure to also use localhost:5000 now :)

SimonDing87 commented 8 years ago

:+1:

kcvan commented 8 years ago

:dango:

polinabythebay commented 8 years ago

:fireworks: :fireworks: merging pr