Giter Site home page Giter Site logo

azat-co / practicalnode Goto Github PK

View Code? Open in Web Editor NEW
3.8K 201.0 693.0 43.43 MB

Practical Node.js, 1st and 2nd Editions [Apress] ๐Ÿ““

Home Page: http://practicalnodebook.com

JavaScript 76.14% CSS 1.47% CoffeeScript 0.18% Shell 3.07% HTML 0.89% Makefile 1.55% Dockerfile 1.12% Pug 14.43% Stylus 1.16%
nodejs apress javascript node-js node-module express expressjs express-js rest-api mocha

practicalnode's People

Contributors

angelogulina avatar art-kan avatar azat-co avatar behroozk avatar biblicalph avatar crisz avatar daniel-vera-g avatar elijahahianyo avatar emirsavran avatar georgyserga avatar ihak avatar joosem avatar junboz avatar m-ketan avatar m4jing avatar monkindey avatar prahaladbelavadi avatar rautility avatar realize096 avatar rorra avatar user135711 avatar vijaybhaskar184 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

practicalnode's Issues

ch5 (book) - missing scripts/css download description

In the book, there is no mention how to download the javascripts/css files, e.g. bower install bootstrap#3.0.2 and bower install jquery#2.0.3. And if one follows the coding instructions without checking out the git source code, one does not see the final UI.

Also missing documentation: how to compile styl files to css. (e.g. stylus -w public/css/style.styl)

serverless examples use outdated dynamodb-doc

A note in its repository says:

As of September 10, 2015, this version of the Document SDK will be deprecated in favor of the AWS.DynamoDB.DocumentClient in the official AWS SDK for JavaScript

I believe examples should be updated...

chapter 6 /auth/twitter HTTP 500 error

I'm having the same issue as in #5

I have set my consumer key and consumer secret as appropriate in Makefile

Could you please go through what settings/permissions the Twitter app requires?

Even a very short and simple step-by-step of creating the app and setting up the permissions would be enough to get this working so we can continue reading the book!

ch 2 - Routes in Express.js

I'm a bit confused by this section. After "However, it's trivial to write your own middleware..." well, an example of a middleware to route by query string arguments is given. And then it says: "The request handler itself (index.js, in this case) is straightforward".

What index.js? The example was not mentioned as being in an index.js file. After all, is an example of something not included in express cli generated project. Is it the index.js in the routes folder? The one shown later is actually users.js.

chapt 1 prototypal typo

https://github.com/azat-co/practicalnode/blob/master/chapter1/chapter1.md#prototypal-nature

var user = function (ops) {
  return { firstName: ops.name || 'John'
         , lastName: ops.name || 'Doe'
         , email: ops.email || '[email protected]'
         , name: function() { return this.firstName + this.lastName}
         }
}

var agency = function(ops) {
  ops = ops || {}
  var agency = user(ops)
  agency.customers = ops.customers || 0
  agency.isAgency = true
  return agency
}

should be

var user = function (ops) {
  return { firstName: ops.firstName || 'John'
         , lastName: ops.lastName || 'Doe'
         , email: ops.email || '[email protected]'
         , name: function() { return this.firstName + this.lastName}
         }
}

var agency = function(ops) {
  ops = ops || {}
  var agency = user(ops)
  agency.customers = ops.customers || 0
  agency.isAgency = true
  return agency
}

Trying to use newest versions of modules, having difficulty.

Is there anybody who can explain how to go about updating this to the newest versions of each module? I installed them, and got the server running, but then when I try to visit the port, I get some errors. If anybody's tried this, and could share their experience, I'd appreciate that.

Typos / Miscellaneous Erata in Kindle Version

  • Chapter 1 (location 873 of 8083) link to "http://callbackhell.com/):" broken
  • Chapter 2 (location 1564 of 8083) reference to process.evn.PORT instead of process.env.PORT
  • Chapter 2 (location 1652 of 8083) Missing opening h1 tag:
"Produces the following HTML code: hello </h1><p>Welcome to the Practical Node.js!</p>" 
  • Chapter 4 (location 2412 of 8083)
    Quote: "hence the name of the library (see the resemblance to handlebars on a bicycle?".
    Handlebars is named as such because it is a nickname for an impressive mustache. It has nothing to do with handlebars on a bicycle.
  • Chapter 8 (location 5014 of 8083): refers to "Anglers JS" instead of "Angular JS".
  • Chapter 8 (location 5465 of 8083): section title says "Hapi RESP API..." instead of "Hapi REST API..."
  • Chapter 9 (Location 5779): example of of "full source code" of browser websocket implementation is missing error handler (ws.onerror = function(event){...} ).

Replace Grunt example

Replace Grunt example with Webpack (Hot Module Replacement) in code and text (chapter 10)

invalid path

The following path 'chapter1/media/Homebrew is causing the git checkout to fail and therefore the cloning succeeds but deletes the contents right after.

ch5 (git) - mongo-skin.js - TypeError: Object #<SkinClass> has no method 'findOneAndAddText'

Moving the file mongo-skin.js to the folder blog-express/ and running node mongo-skin.js gives the following error:

(Using Node.js v0.10.31 and mongoDB 2.6.4)

db.collection('messages').findOneAndAddText('hi', function(count, id){
                          ^
TypeError: Object #<SkinClass> has no method 'findOneAndAddText'
    at Object.<anonymous> (/.../practicalnode/ch5/blog-express/mongo-skin.js:26:27)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

chapter 3 test error

the end's callback function is always be passed two arguments err and response; if no error occurred, the first argument will be null;

request
.get('..')
.end(function(err, res){

});

Tech review all chapters

  • code is working
  • text make sense
  • code is consistent between files and text and in style (standardJS)

400 Error: request size did not match content length

http://stackoverflow.com/questions/26922125/node-js-post-causes-error

0 down vote favorite

I am running this app. the only change is twitter consumer key and secret I made in app.js file

I can run this app and sign-in with twitter. But when I try to post an article it causes error.

Connect
400 Error: request size did not match content length

at makeError (/home/myname/Documents/nodejs/practicalnode/ch7/blog-express/node_modules/body-parser/node_modules/raw-body/index.js:136:15)
at IncomingMessage.onEnd (/home/myname/Documents/nodejs/practicalnode/ch7/blog-express/node_modules/body-parser/node_modules/raw-body/index.js:106:13)
at IncomingMessage.g (events.js:180:16)
at IncomingMessage.emit (events.js:92:17)
at _stream_readable.js:938:16
at process._tickCallback (node.js:419:13)

What should I check?what could be wrong. thanks

Admin Delete Button Calls both Remove & Update functions

This section of code in admin.js calls both remove and update functions, causing a 500 server error because the document gets deleted and when the update function runs it tries to edit a document that doesn't exist.

$(document.ready(function(){
var $element = $('.admin tbody');
$element.on('click','button.remove', remove);
$element.on('click','button', update);
}

I had to change it to:

$element.on('click', 'button.remove', remove);
$element.on('click', 'button.publish', update);
$element.on('click', 'button.unpublish', update);

I'm sure there is a better way to do this

ch5 (book-git) - Mocha test fails on mismatching articles.json in the book and the git source

If one:

  • has two projects, one coded from the book (book project) and another one from git (git project)
  • runs ./db/seed.sh from the git project.
  • runs make test from the book project.

then one test will fail because the first article in the book ends with to improve network coverage... and it does not match the string from the git project to improve network coverage.

Possible solution is to finish the article sentence in the book with a dot, even when the strings are longer.

NEW TOPICS

Please vote on these topics to be included into the 2nd edition:

  • http/2
  • SSL
  • NAPI (native modules)
  • async/await, promises
  • crypto
  • Ethereum, dapps, web3
  • React Native
  • Electron
  • Webpack
  • ES6 modules in Node
  • Babel
  • Docker
  • AWS
  • k8s
  • Axios
  • Fetch API (node fetch npm module)
  • GraphQL server
  • TypeScript or Flow
  • Yarn

ch6 (git) - http://localhost:3000/auth/twitter returns 500 error

Using the source code from git and the recommended start.sh from the book, when I try to sign in with Twitter, I get a 500 error from Express. (Key, Secret and Twitter name are set)

Console output:

starting step - getRequestToken
undefined
GET /auth/twitter 500 5898ms

CH 3 - Mocha tests fails

I'm using the index.js and app.js raw code from git hub to run the mocha test. I'm recieving a timeout and failure when testing.
package

chapter3mochafail
appjs
indexjs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.