This is my repository for the project described in the book Getting MEAN by Simon Holmes. This readme contains notes, screenshots, and readme chapter question responses for each chapter.
Notes
- On P. 315 there is a typo in Listing 10.9, at the top where it says
locationProviderit should be$locationProvider. - On P. 317 there is a typo under Creating The New Common Template it is missing a
<aftervm.main.content. - For a while it would not let me post reviews stating
All fields required, please try again, I fixed this by fixing the spacing inreviewModal.view.html.
Chapter 10 Screenshot
Notes
- I got stuck for a while at the end of 9.3.4 because I had forgotten a comma.
- This chapter was a slightly different version of chapter 8.
Chapter 9 Screenshot
Notes
- The filter functionality seems to be very sensitive. In order to find
Diversions CafeI need to type at leastDiwhere as when I try to findJewel Box CafeI only need to typeJ. - At first I forgot to change the way distances are calculated in
../public/angular/loc8rApp.jsand the distances were calculated in the thousands. - I used
function loc8rData($http) {...}&function geolocation() {...}rather thanvar loc8rData = function($http) {...}&var geolocation = function() {...}as shown in the book.
Chapter 8 README Questions
- With AngularJS being a front-end framework, it means that the machine the code us executed on, is that of the user rather than the server.
- If you put a
console.log()command in your AngularJS controller, you would see the output in the browsers developer console.
Chapter 8 Screenshot
Notes
- I needed to add my google API key in order for the application to correctly display the cafe locations.
- When attempting to post a review with all of the fields filled out, it brings me to the error page displaying
error 400. In terminal it states[MongoError: Unknown modifier: $pushAll]. - I had an error that would not allow me to post reviews. I fixed this by adding
{usePushEach: true}to the end of thevar locationSchemain../app_api/models/locations.jsand usingform.form-horizontal(action="", method="post", role="form")rather thanform#addReview.form-horizontal(action="", method="post", role="form")which is listed in the notes, in..app_server/views/location-review-form.jade.
Chapter 7 README Questions
- Consuming a REST API is a fancy term for using an API as part of your application. We are "consuming" the API set up in chapter 6 because we are using it in chapter 7.
- Deleting either
lng : -122.481541orlat : 47.262259in the homelist module in../app_server/controllers/locations.jswould cause the "API Lookup Error" message. - The bug on P. 215 is that if someone entered a
0forlngorlatdue to being on the equator or Prime Meridian, it would return an API error. This is because JavaScript actively looks for values it considers false, like anempty string,null, or0. The fix for this is to change the condition in thelocationsListByDistancecontroller from:if (!lng || !lat)toif ((!lng && lng!==0) || !lat && lat!==0).
Chapter 7 Screenshot
Notes
- Variables
routesAPIandroutesare calledindexandindexApiin my code. - I had a bit of trouble reading the very specific instructions to make a bunch of different
module.exportsfor the controllers. - I had a problem on page 177 getting my databases to load. The solution to this was to switch the Node version from
4.1.0to4.2.1. - I had a problem after implementing locationsCreate with it returning
TypeError: Cannot read property 'split' of undefinedwhen attempting to post. This was solved by manually entering the information into Postman.
Chapter 6 README Questions
- According to my API routing, the name of the function that will be called when the server receives a request at the
/api/locationsurl islocationsCreate. - The format of the data that the server returns when you make a request to the api URLs is
JSON. - Postman is used for API Development and it is useful because it allows the user to easily test, develop, and document APIs by putting together both simple and complex HTTP requests. Its functionality is similar to a web browser like chrome because it allows you to use a URL to gather and send information requests but is different because it connects to the back end of the server rather than the front end.
Chapter 6 Screenshots
Notes
- It is a lot easier to add data to the database using Robomongo than it is using terminal.
- I now have two mLab accounts due to the book having two separate sets of instructions.
- When my program runs in terminal, it does not return
Express server listening on port 3000. - When my program runs in production mode, it does not return
Express server listening on port 3000norMongoose connected to momgodb://heroku_app...
Chapter 5 README Questions
- Individual database entries in MongoDB are called Documents.
- The difference between the command line commands
mongoandmongodis:mongois the interactive command-line shell that connects to a specific instance ofmongod, andmongodis the host process for the database, the core database process running in the background. mLabprovides a fully managed cloud database service. This allows us the ability to not only store our database, but to back it up, recover, monitor, and manage it.
Chapter 5 Screenshot
Notes
- Google did not require me to enter an API key to imbed Google Maps.
- The misprint in the book is located on page 99. The book tells you the code is in the file
app_server/views/location-info.jswhen the actual file isapp_server/views/location-info.jade. - This version includes the wrap up process described in Appendix C.
- I used Diversions Cafe as the replacement to Starcups.
Chapter 4 README Questions
- The Jade/Pug templates used in Chapter 4 help to avoid unnecessary repetition of code by allowing us to define something once in a layout file, such as
sharedHTMLfunctions.jade, and use it as many times as we want by calling one line. In this case, that line is+outputRating(location.rating). - When the
/locationurl request is received, the route in../routes/index.jscalls thelocationsInfofunction inside of../controllers/locations.jswhich loads the../views/location-info.jadetemplate. - In the MEAN acronym, the letter that is most closely associated with the part of the stack that provides our routing functionality is E: Express. Express is a back-end web framework that allows users to easily create routes, handle cookies, etc.
Chapter 4 Screenshot
Notes
- Created a web application using directions from the book Getting MEAN with Mongo, Express Angular, and Node.
Chapter 3 README Questions
- The process of mapping URL requests to the functionality we want to associate with the URL is called routing.
- The Node command to bring an external module into your code (for the chapter 3 code) is
var index = require('./app_server/routes/index');
var users = require('./app_server/routes/users');- If you put
console.log('This is a console log message')into theapps.jsfile, you see the message in the console after the application has been launched.
17:18:37 web.1 | > book-project@0.0.0 start /Users/benscarbrough/Atom/CSCI 240/Book_Project
17:18:37 web.1 | > node ./bin/www
17:18:37 web.1 | This is a console log message
Chapter 3 Screenshot








