myNodeApps setup

Setting up nsVote

DISCLAIMER: The software is offered as is.

The software has mostly been tested locally on and on


To run the software locally /

Risk of getting stuck
/ making an error
Action nsVote-file
Medium Install Node.js (Google it (Personally I use the "Installing Node.js via binary archive on Linux"-insturctions from
Risky Install MySQL or MariaDB. (MariaDB seem to support TLS which MySql doesn't. On the other hand MySQL Workbench says they might not support MariaDB. Personally I use MariaDB.)
Medium Install Redis (they have pretty good "quick start"-instructions (ref))
Small Download the files: git
Medium In the extracted folder: Run npm install. (This will download the required "modules" (libraries/files) ).
Medium Create a file config.js (for example by copying and editing config.example.js). Read the comments (follow the instructions) of the file. config.example.js
Small In the extracted folder: run:

node script.js --sql createTable (to create the tables)

node script.js --sql createFunction (to create the mysql functions)

node script.js (to run the app)

(run node script.js -h for more options)

To run the software on

Risk of getting stuck / making an error
Medium Get an account at (Free) and make sure you can upload their test programs. (follow their instructions) They will ask you to install git and heroku-toolbelt on your computer.

Git in its own is a tool that might need some practicing to handle.

Small At under add-ons: Add
  • ClearDB (MySQL-database)
  • A redis-implementation (Either Redis to go or Redis cloud).
(Instead of adding ClearDB, you can enter a mysql-url in the config.js-file. (Good for example if you want to share MySQL-database between different heroku apps.) If you want to do this then check the comments of config.example.js (links above))
Small Download the files to your computer (using the links above).
Medium Create a file with the configurations ("config.js") (just as above).
Medium At heroku: Create two environment variables strInfrastructure and jsConfig with for example the following commands (Linux/Bash):

heroku config:set strInfrastructure=heroku

heroku config:set jsConfig="$(cat config.js)"

In other words: jsConfig should contain the content of the "config.js"-file (including newlines). The commands above show how to do that in Linux/Bash. In Windows you might have to do that in an other way.

Note! Heroku also has a web interface where you can add environment variables, but at the time of writing newline-characters are removed from any data that you paste there. (If one removes all one-line comments in config.js it might work (I haven't tried yet))

Medium Use git to upload the software to your heroku account. (Just as you uploaded their test app before)
Small In your console, run:

heroku run node script.js --sql createTable (to create the tables)

heroku run node script.js --sql createFunction (to create the mysql functions)

(run heroku run node script.js -h for more options)

TLS (SSL (https))

I'm currently using TLS with nginx. Making this work is a story of its own.