NodeJS To MongoDB Setup - acmeair/acmeair GitHub Wiki

Download the following software

NodeJS v0.10.X

MongoDB 2.4.X

  • Download link: http://www.mongodb.org/downloads
  • Unzip the zip into some directory
  • For the rest of these instructions we will assume this to be the MONGO_SERVERDIR
cd \work\java
unzip mongodb-win32-x86_64-2.4.3.zip
cd \work\java\mongodb-win32-x86_64-2.4.3
set MONGO_SERVERDIR=C:\work\java\mongodb-win32-x86_64-2.4.3

Install the following development tools

Get the Acme Air codebase

  • Go into a directory that you want to have the code in and use git to clone it
cd \work\eclipse
git clone https://github.com/acmeair/acmeair.git
  • For the rest of these instructions we will assume this to be the ACMEAIR_SRCDIR
set ACMEAIR_SRCDIR=C:\work\eclipse\acmeair

Update the required NPM depdendencies

cd %ACMEAIR_SRCDIR%\acmeair-webapp-nodejs
npm update

Start MongoDB

  • In another window, create a data directory and start mongod with that path
  • Ensure that you have set node and npm in the path as before
cd %MONGO_SERVERDIR%
mkdir data
bin\mongod -dbpath data

Now we will load sample data into MongoDB

  • We do this by running a Acme Air loader program
cd %ACMEAIR_SRCDIR%\acmeair-webapp-nodejs\loader
node loader
  • You should see output that indicates flights and customers (200) were loaded

Start the NodeJS server and Acme Air application

cd %ACMEAIR_SRCDIR%\acmeair-webapp-nodejs
node app

Finally look at the application

  • Load the following url:
http://localhost:3000/
  • Login (use the provided credentials), search for flights (suggest today between Paris and New York), book the flights, use the checkin link to cancel the bookings one at a time, view your account profile

Optionally, if you want you can use eclipse to work with the codebase

  • Tell eclipse to import existing projects into the workspace looking in %ACMEAIR_SRCDIR%