万本电子书0元读

万本电子书0元读

顶部广告

Learning Node.js Development电子书

售       价:¥

7人正在读 | 0人评论 9.8

作       者:Andrew Mead

出  版  社:Packt Publishing

出版时间:2018-01-31

字       数:56.0万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
A comprehensive, easy-to-follow guide to creating complete Node apps and understanding how to build, deploy, and test your own apps. About This Book ? Entirely project-based and practical ? Explains the "Why" of Node.js features, not just the "how", providing you with a deep understanding and enabling you to easily apply concepts in your own applications ? Covers the full range of technologies around Node.js – NPM, version control with Git, and much more Who This Book Is For This book targets anyone looking to launch their own Node applications, switch careers, or freelance as a Node developer. You should have a basic understanding of JavaScript in order to follow this course. What You Will Learn ? Learn the fundamentals of Node ? Build apps that respond to user input ? Master working with servers ? Learn how to test and debug applications ? Deploy and update your apps in the real world ? Create responsive asynchronous web applications In Detail Learning Node.js Development is a practical, project-based book that provides you with all you need to get started as a Node.js developer. Node is a ubiquitous technology on the modern web, and an essential part of any web developers' toolkit. If you are looking to create real-world Node applications, or you want to switch careers or launch a side project to generate some extra income, then you're in the right place. This book has been written around a single goal—turning you into a professional Node developer capable of developing, testing, and deploying real-world production applications. Learning Node.js Development is built from the ground up around the latest version of Node.js (version 9.x.x). You'll be learning all the cutting-edge features available only in the latest software versions. This book cuts through the mass of information available around Node and delivers the essential skills that you need to become a Node developer. It takes you through creating complete apps and understanding how to build, deploy, and test your own Node apps. It maps out everything in a comprehensive, easy-to-follow package designed to get you up and running quickly. Style and approach This book is entirely project-based. From the very beginning you'll be programming every single app and completing various challenges designed to help test and reinforce what you've learned. There's no copying-and-pasting here. This book is about writing code and building projects.
目录展开

Title Page

Copyright and Credits

Learning Node.js Development

Packt Upsell

Why subscribe?

PacktPub.com

Contributor

About the author

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Conventions used

Get in touch

Reviews

Getting Set Up

Node.js installation

Node.js version confirmation

Installing Node

Verifying installation

What is Node?

Differences between JavaScript coding using Node and in the browser

Why use Node

Blocking and non-blocking software development

The working of blocking I/O

The working non-blocking I/O

Blocking and non-blocking examples using Terminal

Node community – problem solving open source libraries

Different text editors for node applications

Hello World – creating and running the first Node app

Creating the Node application

Running the Node application

Summary

Node Fundamentals – Part 1

Module basics

Using case for require()

Initialization of an application

The built-in module to use require()

Creating and appending files in the File System module

The OS module in require()

Concatenating user.username

Using template strings

Require own files

Making a new file to load other files

Exporting files from note.js to use in app.js

A simple example of the working of the exports object

Exporting the functions

Exercise – adding a new function to the export object

Solution to the exercise

Third-party modules

Creating projects using npm modules

Installing the lodash module in our app

Installation of lodash

Using the utilities of lodash

Using the _.isString utility

Using _.uniq

The node_modules folder

Global modules

Installing the nodemon module

Executing nodemon

Getting input

Getting input from the user inside the command line

Accessing the command-line argument for the notes application

Adding if/else statements

Exercise – adding two else if clauses to an if block

Solution to the exercise

Getting the specific note information

Summary

Node Fundamentals – Part 2

yargs

Installing yargs

Running yargs

Working with the add command

Working with the list command

The read command

Dealing with the errors in parsing commands

The remove command

Fetching command

JSON

Converting objects into strings

Defining a string and using in app as an object

Converting a string back to an object

Storing the string in a file

Writing the file in the playground folder

Reading out the content in the file

Adding and saving notes

Adding notes

Adding notes to the notes array

Fetching new notes

Trying and catching code block

Making the title unique

Refactoring

Moving functionality into individual functions

Working with fetchNotes

Working with saveNotes

Testing the functionality

Summary

Node Fundamentals – Part 3

Removing a note

Using the removeNote function

Printing a message of removing notes

Reading note

Using the getNote function

Running the getNote function

The DRY principle

Using the logNote function

Debugging

Executing a program in debug mode

Working with debugging

Using debugger inside the notes application

Listing notes

Using the getAll function

Advanced yargs

Using chaining syntax on yargs

Calling the .help command

Adding the options object

Adding the title

Adding the body

Adding support to the read and remove commands

Adding the titleOption and bodyOption variables

Testing the remove command

Arrow functions

Using the arrow function

Exploring the difference between regular and arrow functions

Exploring the arguments array

Summary

Basics of Asynchronous Programming in Node.js

The basic concept of asynchronous program

Illustrating the async programming model

Call stack and event loop

A synchronous program example

The call stack

Running the synchronous program

A complex synchronous program example

An async program example

The Node API in async programming

The callback queue in async programming

The event loop

Running the async code

Callback functions and APIs

The callback function

Creating the callback function

Running the callback function

Simulating delay using setTimeout

Making request to Geolocation API

Using Google Maps API data in our code

Installing the request package

Using request as a function

Running the request

Pretty printing objects

Using the body argument

Making up of the HTTPS requests

The response object

The error argument

Printing data from the body object

Printing the formatted address

Printing latitude and longitude

Summary

Callbacks in Asynchronous Programming

Encoding user input

Installing yargs

Configuring yargs

Printing the address to screen

Encoding and decoding the strings

Encoding URI component

Decoding URI component

Pulling the address out of argv

Callback errors

Checking error in Google API request

Adding the if statement for callback errors

Adding if else statement to check body status property

Testing the body status property

Abstracting callbacks

Refactoring app.js and code into geocode.js file

Working on request statement

Creating geocode file

Adding callback function to geocodeAddress

Setting up the function in geocodeAddress function in app.js

Implementing the callback function in geocode.js file

Testing the callback function in geocode.js file

Wiring up weather search

Exploring working of API in the browser

Exploring the actual URL for code

Making a request for the weather app using the static URL

Error handling in the the callback function

Another way of error handling

Testing the error handling in callback

Chaining callbacks together

Refactoring our request call in weather.js file

Defining the new function getWeather in weather file

Providing weather directory in app.js

Passing the arguments in the getWeather function

Printing errorMessage in the getWeather function

Implementing getWeather callback inside weather.js file

Adding dynamic latitude and longitude

Changing console.log calls into callback calls

Chaining the geocodeAddress and getWeather callbacks together

Moving getWeather call into geocodeAddress function

Replacing static coordinates with dynamic coordinates

Testing the chaining of callbacks

Summary

Promises in Asynchronous Programming

Introduction to ES6 promises

Creating an example promise

Calling the promise method then

Running the promise example in Terminal

Error handling in promises

Merits of promises

Advanced promises

Providing input to promises

Returning the promises

Promise chaining

Error handling in promises chaining

The catch method

The request library in promises

Testing the request library

Weather app with promises

Fetching weather app code from the app.js file

Axios documentations

Installing axios

Making calls in the app-promise file

Making axios request

Error handling in axios request

Error handling with ZERO_RESULT body status

Generating the weather URL

Chaining the promise calls

Summary

Web Servers in Node

Introducing Express

Configuring Express

Express docs website

Installing Express

Creating an app

Exploring the developer tools in the browser for the app request

Passing HTML to res.send

Sending JSON data back

Error handling in the JSON request

The static server

Making an HTML page

The head tag

The body tag

Serving the HTML page in the Express app

The call to app.listen

Rendering templates

Installing the hbs module

Configuring handlebars

Our first template

Getting the static page for rendering

Injecting data inside of templates

Rendering the template for the root of the website

Advanced templates

Adding partials

Working of partial

The Header partial

The Handlebars helper

Arguments in Helper

Express Middleware

Exploring middleware

Creating a logger

Printing message to file

The maintenance middleware without the next object

Testing the maintenance middleware

Summary

Deploying Applications to Web

Adding version control

Installing Git

Git on macOS

Git on Windows

Testing the installation

Turning the node-web-server directory into a Git repository

Using Git

Adding untracked files to commit

Making a commit

Setting up GitHub and SSH keys

Setting up SSH keys

SSH keys documentations

Working on commands

Generating a key

Starting up the SSH agent

Configuring GitHub

Testing the configuration

Creating a new repository

Setting up the repository

Deploying the node app to the Web

Installing Heroku command-line tools

Log in to Heroku account locally

Getting SSH key to Heroku

Setting up in the application code for Heroku

Changes in the server.js file

Changes in the package.json file

Making a commit in Heroku

Running the Heroku create command

Summary

Testing the Node Applications – Part 1

Basic testing

Installing the testing module

Testing a Node project

Mocha – the testing framework

Creating a test file for the add function

Creating the if condition for the test

Testing the squaring a number function

Autorestarting the tests

Using assertion libraries in testing Node modules

Exploring assertion libraries

Chaining multiple assertions

Multiple assertions for the square function

Exploring usage of expect with bogus test

Using toBe and toNotBe to compare array/objects

Using the toEqual and toNotEqual assertions

Using toInclude and toExclude

Testing the setName method

The asynchronous testing

Creating the asyncAdd function using the setTimeout object

Writing the test for the asyncAdd function

Making assertion for the asyncAdd function

Adding the done argument

The asynchronous testing for the square function

Creating the async square function

Writing test for asyncSquare

Making assertions for the asyncSquare function

Summary

Testing the Node Applications – Part 2

Testing the Express application

Setting up testing for the Express app

Testing the Express app using SuperTest

The SuperTest documentation

Creating a test for the Express app

Writing the test for the Express app

Testing our first API request

Setting up custom status

Adding flexibility to SuperTest

Creating an express route

Writing the test for the express route

Organizing test with describe()

Adding describe() for individual methods

Adding the route describe block for the server.test.js file

Test spies

Creating a test file for spies

Creating a spy

Setting up spies assertions

More details out of spy assertion

Swapping of the function with spy

Installing and setting up the rewire function

Replacing db with the spy

Writing a test to verify swapping of the function

Summary

Conclusion

Another Book You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部