Errata

Web Development with Node and Express

Errata for Web Development with Node and Express

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Other Digital Version Chapter 2, Routing example

Reading book on Amazon Kindle Cloud Reader.

RegEx expression for removing query string seems to be unnecessary complicated. You use

/\/?(?:\?.*)?$/

Why is there an uncapturing group of (?:\?.*) ?

Isn't the whole thing equivalent to simply

/\/?\?.*?$/

Vladimir Kelman  May 11, 2016 
Other Digital Version 1
shop.oreilly.com/product/0636920032977.do

Near the top of the page //shop.oreilly.com/product/0636920032977.do the author is listed as "Todd Brown" instead of "Ethan Brown" though the link appears to be correct.

David Brown  Oct 16, 2018 
Printed Page 21
first line

node_modules dirctory can be regenerated at any time with npm
should be:
node_modules directory can be regenerated at any time with npm

Anonymous  Oct 29, 2015 
Printed Page 26
Last sentence on page

In Chapter 3 the image was logo.png. Previously, in Chapter 2, page 16, it was logo.jpg. It would be best to be consistent for beginning developers.

Anonymous  Dec 01, 2015 
PDF Page 46
3rd line

Zombie 3.1.1 does not work with the supplied test code, but does work with 2.5.1.

There seems to have been changes in the API between the two versions but a lack of documentation from the author of Zombie makes it difficult to translate between them.

Ryan Breaker  Aug 05, 2015 
PDF Page 46
3rd line

With the specified version 3.1.1 of Zombie, after Zombie does the "clickLink" to the request-group-rate page, the document.referrer field is empty, so the jQuery function which places the referrer page into the hidden field will always set that hidden field to be empty. This may be a bug with Zombie 3.1.1. The effect of this is that the first two tests in qa/tests-crosspage.js will always fail.
I haven't been able to figure out a workaround for this.

Graeme Falkner  Aug 09, 2015 
PDF Page 49
last paragraph, 2nd sentance

... and this is where many a QA plan withers and dies.

unambiguous reference to:

... and this is where many QA plans wither and die.
or
... and this where a QA plan withers and dies.

Saif Aljashamy  Nov 08, 2015 
PDF Page 58
under req.cookie

Object containing containing cookie values passed...

should be:

Object containing cookie values passed...

Saif Aljashamy  Nov 08, 2015 
PDF Page 62
example 6-5 comment

// the layout file views/layouts/custom.handlebars

from the code, it should be:

// the layout file views/layouts/custom-layout.handlebars

Saif Aljashamy  Nov 08, 2015 
Printed, PDF Page 63
Last paragraph

The last paragraph on page 63 and Example 6-3 on page 64 reference the 'req.session' array/object; however, there is no mention of this property in the "The Request Object" section on pages 59-60. Given its importance, it should probably be included.

Eric  Dec 21, 2015 
PDF Page 64
first line of page

res.render({ success: true });

should be:

res.json({ success: true });

Saif Aljashamy  Nov 08, 2015 
PDF Page 65
top page code

'text/plain': function(){
res.type('text/plain');
res.send(toursXml); // <-
}

should be:
res.send(toursText);

Saif Aljashamy  Nov 08, 2015 
Other Digital Version 65
Example 6-10. More robust form processing

Example 6-10. More robust form processing

return res.xhr ?

shouldnt this be req.xhr ?

raj_kris  Oct 08, 2016 
Printed Page 67
Example 6-13

if (p) is always evaluated true even if p is an empty array.
So res.json({error: 'No such tour exists.'}); would never be executed.

if (p) can be changed to if (p.length).

sung byun  Dec 03, 2015 
ePub Page 71
Code in the last paragraph

Following code reports "Error: Missing helper: "section""
{{#section 'jquery'}}

This is due to the "section" is not defined in the file meadowlark.js
It is is introduced on the page 110:

var handlebars = require('express-handlebars').create({
defaultLayout:'main',
helpers: {
section: function(name, options){
if(!this._sections) this._sections = {};
this._sections[name] = options.fn(this);
return null;
} }
});

smreo  Aug 29, 2016 
PDF Page 75
first line of page

<!doctype>

should be:

<!doctype html>

Saif Aljashamy  Nov 11, 2015 
PDF Page 75
The latest paragraph

In "Because of the order of operations, you can pass a property called
body into the view, ...", the "view" should be "layout", since the {{{body}}} is paced in layout file.

Neo Tan  Dec 17, 2016 
Printed Page 76
Figure 7-2

In figure 7-2, "laouts/main.handlebars" should be "layouts/main.handlebars".

Bran Taylor  Jan 31, 2016 
Printed Page 78
end of the "function getWeatherData()" function example

remove extra commas at the end of each block:

temp: '54.1 F (12.3)', // remove this comma
...

temp: '55.0 F (12.8)', // remove this comma
....

temp: '55.0 F (12.8)', // remove this comma
}, // remove this comma
], // remove this comma

Anonymous  Jan 02, 2016 
PDF Page 93
3rd line of code

action="/contest/vacation-photo/{year}/{month}"

should be:

action="/contest/vacation-photo/{{year}}/{{month}}"

Saif Aljashamy  Nov 11, 2015 
PDF Page 93
Code

The code fragment for the file views/contest/vacation-photo.handlebars has problem with its form tag's action attribute value. The handlebars expression is not correct.

It's written as follows:

/contest/vacation-photo/{year}/{month}

But, ideally it should have been:

/contest/vacation-photo/{{year}}/{{month}}


Anonymous  Nov 17, 2015 
Printed Page 112
5th line on the page

instead of:
app.get('/c', function(err, req) {...

should be:
app.get('/c', function(req,res) {...

Anonymous  Jan 02, 2016 
Printed Page 124
3rd paragraph, codeblock: line 7

.slice(i * recipientLimit, i * (recipientLimit + 1)).join(',')

should be:

.slice(i * recipientLimit, (i + 1) * recipientLimit).join(',')

Anonymous  Nov 09, 2016 
PDF Page 134
last part of the page

In the app.use() middleware function, next() should be called otherwise the client requests will hang.
You mentioned similar word of caution in the previous chapter.

Anonymous  Dec 26, 2015 
PDF Page 134
Vew worker handling request

This code:

app.use(function(req,res,next){
var cluster = require('cluster');
if(cluster.isWorker) console.log('Worker %d received request',
cluster.worker.id);
});

Is missing the call to

next();

Causing the app to hang.

Anonymous  Apr 01, 2016 
Printed Page 136
Very last code sample at the bottom of the page

In the middleware to log the ID of the worker upon receiving a request, "next()" is not called at the end of the middleware. As a result, the request is terminated without being passed on to subsequent middlewares. This in turn causes the server to send no response back to the client, causing the client to hang until timeout occurs.

Suggested fix: call next() at the end of the middleware's callback function.

Dinh Nguyen Nguyen  Sep 12, 2016 
PDF Page 144
Line 6 of app.post route

The erring code is in the if block:
if (err){
res.session.flash={
...
}

Shouldn't it be req.session.flash?

Oluwole  Jul 06, 2017 
PDF Page 152
bottom

There is a reference about updating data that has been already covered in the book somewhere, but I cannot seem to find it in the book. Here is the exerpt:
------------------------------------------------------------
We’ve already seen how we can add data (we added data when we seeded the vacation
collection) and how we can update data (we update the count of packages sold when we book a vacation)
----------------------------------------------------------


Where in the book it is shown how to update the count of packages sold?

Anonymous  Feb 15, 2019 
PDF Page 157
2nd code block

Where it says

app.status(500).render('500')

it should be

res.status(500).render('500')

Anonymous  Aug 18, 2015 
Printed Page 227
Code snippet, middle of page

Both in the book and in the downloaded sample code, the passport.deserializeUser() function looks like this:

passport.deserializeUser(function(id, done) {
User.findById( id, function(err, user){
...
});
});

I have trouble seeing how the id passed in to deserializeUser() could ever match a MongoDB document ID. I ended up changing my code to:

passport.deserializeUser(function(authId, done) {
User.findOne( { authId: authId }, function(err, user){
...
});
});

to solve the problem.

Eric Hill  Jun 24, 2016 
Mobi Page 1397
middle

Chapter 5, section: Cross-Page Testing
The code for the page "views/tours/request-group-rate.handlebars"
includes:
{{#section 'jquery'}}
However the code to create a "#section" helper does not occur until Chapter 7 in the section "Sections".
Without this helper code, the example will fail with a
Error: Missing helper: "section"
error.
Sorry I can't give page numbers because the Kindle version doesn't use page numbers.

Graeme Falkner  Aug 07, 2015 
PDF, ePub, Mobi Page 18749
text

Typos:

Current Copy
Finally, no matter what sytem you’re on, there’s the excellent Codio.

Suggested
"sytem" should be "system"



Current Copy
Since the node_modules dirctory can be regenerated at any time with npm, we will not save it in our repository.

Suggested
"dirctory" should be "directory"


Current Copy
This osbscured the fact that this middleware was actually part of Connect.

Suggested
"osbscured" should be "obscured"


Current Copy
you use keyword monitors. For example, if you religiously include they keyword “server failure” when your website reports an error, keyword

Suggested
"religiously include they keyword" should be "religiously include the keyword"


Current Copy
list. We’re doing that because we don’t want to keep readding our seed vacations: if there are already vacations in the

Suggested
"readding" should be "reading"


Current Copy
Keep this in mind and make sure there’s no other option before using a subdomain for content that is imporant to your SEO plan.

Suggested
"imporant" should be "important"


Current Copy
Unlike our previous experience with the commnad-line debugger, your application is already running: all of the middleware has been linked in, and the app is listening.

Suggested
"commnad-line" should be "command-line"

Anonymous  Sep 18, 2019