- fork this repo
- git clone to your local computer then
cd kwitter-api - setup your database:
createdb kwitter(you must have postgresql installed to have this command)
- create your
.envfile:cp .env.example .env
- edit the
.envfile to look like:
DATABASE_URL=postgres://127.0.0.1/kwitter
JWT_SECRET=whateveryouwant
GOOGLE_CLIENT_ID=whateveryouwant
GOOGLE_CLIENT_SECRET=whateveryouwant
-
From the command line, type
npm install -
From the command line, type
node index.jsornodemon index.jsconfirm that the api is working locally by making a request to
GET localhost:3000/messagesnote: visiting
localhost:3000will take you to a swagger/openapi documentation page for the available api endpoints. -
Create your heorku app from the commandline:
heroku create your-api-name -
Setup a postgres database addon for your heroku app:
heroku addons:create heroku-postgresql -
Confirm that a
DATABASE_URLvariable was added to your heroku app:heroku config -
Setup your config variable for the
JWT_SECRETfor your heroku app:heroku config:set JWT_SECRET=whateveryouwant -
Setup yuor config variable for
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETfor yur heroku app:heroku config:set GOOGLE_CLIENT_ID=whateveryouwant && heroku config:set GOOGLE_CLIENT_SECRET=whateveryouwant -
Push code to your heroku app:
git push heroku master -
Run
heroku logs --tailto watch logs in real-time to confirm that the status of the app has started up successfully -
Open your app with
heroku open-- this should automatically take you to the openapi documentation page which lists all the server endpoints. -
For more help, refer to this guide https://devcenter.heroku.com/articles/getting-started-with-nodejs as well as other Heroku docs for more information on adjusting config vars and adding a postgres db on Heroku