Requires NodeJS, NPM, and MongoDB.
Remote DB is for production use ONLY. Use a local mongodb or setup a Heroku dev env for testing.
If updating any API make sure the documentation is up to date.
http://docs.dorkapi.apiary.io/
- Start a MongoDb instance (only required if using local mongodb; not necessary if pointing to dev or prod DB via config file)
> mongod
- Note: You must have database path already set up on local machine or mongo won't run.
- Type
heroku local
to start instance.- Note: Mongo must be started first or web app won't run.
- Test that the server is running by going to
localhost:5000
in your browser.
- Open command prompt (Windows) or Terminal (Mac/Linux) and navigate to the project's working folder (
dork_api
). - Get the config vars from Heroku with
heroku config --app dork-prod
- Find the
MONGOLAB_URI
value. It will be in the form of:mongodb://<username>:<password>@<url>:<port>/<database>
- Find the
- Run the following command to make a copy of the production database to your local working directory.
- Use the values from the config file:
mongodump -h <url>:<port> -d <database> -u <username> -p <password>
mongodump
will create the following directory to store the data:dump/<database>/
- Use the values from the config file:
- Make sure your local instance of
mongod
is running. - Drop your existing local database with the following command.
mongo dorkdb --eval "db.dropDatabase()"
- Use
mongorestore
to put the prod data into your local mongodb.mongorestore -d dorkdb dump/<database>/
- Ensure data was restored
- Start mongo command line interface:
mongo
- Show databases and ensure
dorkdb
is in the list:> show databases
- Switch to
dorkdb
:> use dorkdb
- Ensure
games
andplayers
tables exist:> show collections
- If satisfied, then exit mongo command line:
> exit
- Start mongo command line interface:
- Run the app and see the prod data (see "Running" section below)
- ???
- Profit!
- This will read from/write to the local Mongo database only. See step 5 to read from/write to remote databases.
- Download the Heroku Toolbelt and install: https://toolbelt.heroku.com/
- Windows Only:
- Make sure Heroku is installed to C:\heroku and mongo is installed to C:\mongodb instead of Program Files.
- Ensure the paths to NPM, Node, and Heroku are registered as environment variables after installation of packages.
- Open a command prompt, navigate to the Dork API working folder, and make sure the packages are installed by typing
npm install
- Optional: Grab the Heroku configuration file if you want to use the remote database instead of local (ref: https://devcenter.heroku.com/articles/config-vars)
- Open a command prompt and navigate to working directory's root folder
- Download the heroku config plugin by typing
heroku plugins:install git://github.com/ddollar/heroku-config.git
- After the plugin is installed, grab the dev config by typing
heroku config:pull --app dork-dev
- Add the
.env
file to.gitignore
Please do not do anything that is not free. My card is attached to the account and I'll discontinue service immediately if unexpected charges show up.
There is an app on Heroku for each environment.
- app.js - starting point. Update this when adding new routes
- routes - Has all controllers
- models - Has all mongodb models
- models/index.js - Update this when adding new models.