Professional Node.js: Building Javascript Based Scalable Software

Professional Node.js: Building Javascript Based Scalable Software

Language: English

Pages: 408

ISBN: 1118185463

Format: PDF / Kindle (mobi) / ePub


Learn to build fast and scalable software in JavaScript with Node.js

Node.js is a powerful and popular new framework for writing scalable network programs using JavaScript. This no nonsense book begins with an overview of Node.js and then quickly dives into the code, core concepts, and APIs. In-depth coverage pares down the essentials to cover debugging, unit testing, and flow control so that you can start building and testing your own modules right away.

  • Covers node and asynchronous programming main concepts
  • Addresses the basics: modules, buffers, events, and timers
  • Explores streams, file systems, networking, and automated unit testing
  • Goes beyond the basics, and shares techniques and tools for debugging, unit testing, and flow control

If you already know JavaScript and are curious about the power of Node.js, then this is the ideal book for you.

Android Wireless Application Development, Volume 2: Advanced Topics (3rd Edition) (Developer's Library)

Learning Perl (6th Edition)

Pathologies of Power: Health, Human Rights, and the New War on the Poor

Build Your Own Website The Right Way Using HTML & CSS (3rd Edition)

Handbook of Open Source Tools

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

form(method="POST", action="/users") p label(for="username") Username
input#username(name="username") p label(for="full_name") Full name (first and last)
input#full_name(name="full_name") p label(for="email") Email
input#email(name="email") p label(for="password") Password
input#password(type="password", name="password") p label(for="gender") Gender
input#gender(name="gender") p label(for="birthday") Birthday
input#birthday(name="birthday") p

Encoding to be used on setEncoding of the response data. If encoding is set to null, the body is returned as a buffer. pool – A hash object containing the agents for these requests. If this option is omitted, this request will use the global pool that’s set to Node’s default maxSockets. pool.maxSockets – Integer containing the maximum number of sockets in the pool. timeout – Integer containing the number of milliseconds to wait for a request to respond before aborting. Creating a Testing

debugger Using a visual Node debugger Building functional software is not a trivial task. Dividing your application code into small modules and testing each one thoroughly can help, but you’re still bound to find problems. If you find yourself in a situation where you need to inspect the inner workings of your Node application or module code, several tools can help. This chapter covers several of those debugging tools – console.log, Node’s built-in debugger, and Node Inspector. USING

boundary=----------------------------cfb73467cea3 Now you can test the JSON encoding. curl doesn’t natively support this encoding; you have to do it yourself: $ curl -d '{"a":"b","c":"d"}' http://localhost:8080 {"{\"a\":\"b\",\"c\":\"d\"}":""} Here you can see that req.body contains a string; Connect failed to parse the request body and handed you a string instead. That’s because you didn’t indicate that the content type would be application/json. You should set this request header when using

input#name(name="name") p label(for="bio") Bio
textarea#bio(name="bio") p input(type="submit", value="Create") This template contains a simple form for creating a user. When pressing the Create button, a POST request is made to the /users URL, activating this route listener: app.post('/users', function(req, res) { if (users[req.body.username]) { res.send('Conflict', 409); } else { users[req.body.username] = req.body; res.redirect('/users'); } }); In the first line of this listener

Download sample

Download