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.

CLR via C# (4th Edition)

The Green Scorecard: Measuring the Return on Investment in Sustainable Initiatives

.net [UK] (May 2015)

Software Requirements (3rd Edition)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Servers WHAT’S IN THIS CHAPTER? Creating an HTTP server Making an HTTP server listen on a port Handling HTTP requests Observing request headers Listening for and piping request data Replying with a status code and headers Replying with a body Using HTTP chunked responses to stream the response body HTTP is an application-level protocol for content and application delivery. It uses TCP as its transport protocol, and it is the foundation of data communication for the World Wide Web.

fs.createWriteStream('/tmp/test.txt'); http.request(options, function(res) { res.pipe(file); }).end(); Here you are creating a file write stream and piping the response body into it. As body data arrives from the server response, it’s written into the file. When the body ends, the file stream is ended, which then closes the file. POOLING SOCKETS USING HTTP.AGENT When making HTTP requests, Node internally uses an agent. An agent is the entity in Node that makes HTTP requests for you. This

request underscore Using package.json to Define Dependencies When coding a Node application, you can also include a package.json file at the root. The package.json file is where you can define some of your application metadata, such as the name, authors, repository, contacts, and so on. This is also where you should specify extraneous dependencies. You don’t need to use it to publish the application to NPM — you may want to keep that application private — but you can still use

"theladyisatramp" }, "jobim": { "username": "jobim", "name": "Antonio Carlos Jobim", "bio": "Composer", "password": "garotadeipanema" }, "fred": { "username": "fred", "name": "Fred Astaire", "bio": "Dancer and Actor", "password": "tophat" } } Also, you’ll need to add a password field to the signup form (views/users/new.jade), seen in Listing 21-14: LISTING 21-14: The new version of the user signup form. h1 New User form(method="POST", action="/users") p label(for="username") Username

io.connect('http://localhost:4000'); socket.on('serverMessage', function(content) { addMessage(content); }); var inputElement = document.getElementById('input'); inputElement.onkeydown = function(keyboardEvent) { if (keyboardEvent.keyCode === 13) { socket.emit('clientMessage', inputElement.value); inputElement.value = ''; return false; } else { return true; } }; This implements the simplest chat use case. When you start the chat server with node server.js and open

Download sample

Download