The if statement provides two different sets of information, depending on whether the app is running locally or on AppFog. generate_mongo_url creates appropriate connection information for MongoDB, which is then assigned to mongourl.

Test

$ curl mongo-node-example.aws.af.cm
Hello World

Add MongoDB Configuration

Your app is now deployed and has a new mongodb service bound to it, but it's not using the service yet. Next, we'll configure the app to use the MongoDB connection information and credentials, both locally and on AppFog.

The if statement provides two different sets of information, depending on whether the app is running locally or on AppFog. generate_mongo_url creates appropriate connection information for MongoDB, which is then assigned to mongourl.