Skip to content

Instantly share code, notes, and snippets.

@JonAbrams

JonAbrams/.gitignore

Last active Aug 29, 2015
Embed
What would you like to do?
Getting a Synth app running on heroku
node_modules
var synth = require('synth');
/* Connect to Mongo DB */
var db = require('promised-mongo')(process.env.MONGODB || 'synth-default-db');
/* Provide DB connection to request handlers */
synth.app.use(function (req, res, next) {
req.db = db;
next();
});
var app = module.exports = synth();
if (!process.env.HEROKU) return;
var port = Number(process.env.PORT || 5000);
app.listen(port, function () {
console.log('Listening on port ' + port);
});

I've ported the "blurbs" demo app to work on heroku. You can find that branch here.

See it live: http://blurbs.herokuapp.com/blurbs

How-to (starting from your project's root):

  1. Add a Procfile to your project's root (see below)
  2. Move back/packages.json to the project's root: mv back/packages.json .
  3. Move back/node_modules to the project's root: mv back/node_modules .
  4. Create a symlink for back/node_modules: cd back; ln -s ../node_modules .; cd ..
  5. Update your .gitignore (see above)
  6. Update back/back-app.js to launch itself if it detects that it's running on heroku (see below)
  7. Add a config var for the app to know it's on heroku: heroku config:set HEROKU=Hi
  8. Make sure you have a MONGODB config var with the URL to the DB you have set up in heroku (or whatever DB you want). Or feel free to change the config var referenced in back-app.js
  9. Add all the new stuff, including the entire contents of front/bower_components to git: git add -u .; git commit
  10. Deploy! git push heroku
web: node back/back-app.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment