packtpublishing / node.js_design_patterns_second_edition_code Goto Github PK
View Code? Open in Web Editor NEWCode repository for Node.js Design Patterns Second Edition, published by Packt
Code repository for Node.js Design Patterns Second Edition, published by Packt
The spiderLinks
function is supposed to be asynchronous, but it seems that the callback
will be executed synchronously in case utilities.getPageLinks(currentUrl, body)
returns an empty array.
When I start the API and web server, both start without issue. However, when I navigate a browser to localhost:300, the terminal responds with "TypeError: loadPropsOnServer is not a function."
When I remove .default from require('async-props').default and run both the API and web server, then navigate the browser to that page, the page hangs and here is a response in the web server terminal:
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).
Any clues?
Chapter 10 - Service Registry
unregisterService listener is asynchronous
Process Event: 'exit' listener must be synchronous
All examples are missing the appropriate code of the [ authsrv-plugin-logout ] package.
The promisify function (Chapter04/01_promisify.js) contains a reference to the arguments
variable in the callback which happens to be an arrow function (with lexical arguments
).
Please find attached a test which demonstrates the problem.
Thank you.
The createProxy
function (Chapter03/09_proxy_c) has a reference to this
, in the patched version of the hello
method, which happens to be an arrow function (with lexical this
).
Please find a test attached to demonstrate the problem. Thank you.
For the section above in chapter 8, the book states use "node server" to start the server.
The source code readme , however, states "you need to run the server using babel-cli: 'node_modules/.bin/babel-cli server.js'"
Neither of them work and both return the following error: "let markup = ReactDom.renderToString(<Router.RouterContext {...renderProps} />);
SyntaxError: Unexpected token < "
node_modules/authsrv-plugin-logout mentioned in chapter 07 example 05_plugin_module_impersonation does not exist
i run cmd with your code:
$ node spider.js http://frps.eflora.cn/frps/Rosales
then a err comes--the file content i write to is undefined
{1} .
function dowload(){
//...
writeFile(filename, body))//{1}
//...
}
i think it may be good to change sth in :
_agruments
to save the aguments for function promisified({1}
){2},{3}
) ,not agruments
{0}
)-or change (not testing
) args.push(function(err, result) { ...}
to args.push((err, result)=>{...}
function promisify (callbackBasedApi) {
return function promisified() {
const args = [].slice.call(arguments);
const _arguments = arguments; //{1}
return new Promise((resolve, reject) => {
args.push(function(err, result) { //{0}
if(err) {
return reject(err);
}
if(_arguments.length <= 1) { //{2}
resolve(result);
} else {
resolve([].slice.call(_arguments, 1)); //{3}
}
});
callbackBasedApi.apply(null, args);
});
}
};
it may lead to the result of request
operation in download
function:
function dowload(){
//...
return request(url)
.then(response => {
body = response.body;
//console.log(JSON.stringify(response));
//the response is an array with length 2 . But it expect to an object since `request(url)`
})
//...
}
thanky you !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.