Node Cookbook [4 ed.] 9781838558758, 1838558756


768 35 14MB

English Pages [512] Year 2020

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Cover
Title Page
Copyright and Credits
About Packt
Contributors
Table of Contents
Preface
Chapter 1: Introducing Node.js 14
Technical requirements
Installing Node.js 14 with nvm
Getting ready
How to do it…
How it works…
There's more…
See also
Accessing the Node.js API documentation
Getting ready
How to do it…
How it works…
There's more…
Adopting new JavaScript syntax in Node.js 14
Getting ready
How to do it…
How it works…
Chapter 2: Handling I/O
Technical requirements
Handling standard I/O
Getting ready
How to do it
How it works
See also
Managing files with fs module
Getting ready
How to do it
How it works
There's more
See also
Inspecting file metadata
Getting ready
How to do it
How it works
There's more
See also
Watching for file updates
Getting ready
How to do it
How it works
See also
Creating TCP server and client communication
Getting ready
How to do it
How it works
There's more
Chapter 3: Streams, Streams, Streams
Technical requirements
Creating streams in Node.js
Getting ready
How to do it…
How it works…
There's more…
See also
Interacting with paused streams
Getting ready
How to do it…
How it works…
See also
Piping streams
Getting ready
How to do it…
How it works…
There's more…
See also
Transforming data with transform streams
Getting ready
How to do it…
How it works…
There's more…
See also
Building stream pipelines
Getting ready
How to do it…
How it works…
There's more…
See also
Chapter 4: Using Web Protocols
Technical requirements
Using http module to make HTTP requests
Getting ready
How to do it…
How it works…
There's more…
See also
Building an HTTP server to accept GET requests
Getting ready
How to do it…
How it works…
There's more…
See also
Handling HTTP POST requests
Getting ready
How to do it…
How it works…
There's more…
See also
Using formidable to handle file uploads
Getting ready
How to do it…
How it works…
There's more…
See also
Using ws to create a WebSocket server
Getting ready
How to do it…
How it works…
There's more…
See also
Sending an automated email using your own SMTP server
Getting ready
How to do it…
How it works…
There's more…
See also
Chapter 5: Developing Node.js modules
Technical requirements
Consuming Node.js modules
Getting ready
How to do it
How it works
There's more
See also
Setting up your own module
Getting ready
How to do it
How it works
There's more
See also
Implementing your module
Getting ready
How to do it
How it works
There's more
See also
Preparing and publishing your module to npm
Getting ready
How to do it
How it works
There's more
Using ECMAScript modules
Getting ready
How to do it
How it works
See also
Chapter 6: Exploring Node.js web Frameworks
Technical requirements
Building web applications with Express.js
Getting ready
How to do it
How it works…
There's more…
See also
Building web applications with Koa.js
Getting ready
How to do it
How it works…
There's more…
See also…
Building web applications with Fastify
Getting ready
How to do it
How it works…
There's more…
See also…
Building web applications with Hapi
Getting ready
How to do it
How it works…
There's more…
See also…
Chapter 7: Working with Databases
Technical requirements
Connecting and persisting to a MySQL database
Getting ready
How to do it…
How it works…
There's more…
See also
Connecting and persisting to a PostgreSQL database
Getting ready
How to do it…
How it works…
There's more…
See also
Connecting and persisting to MongoDB
Getting ready
How to do it…
How it works…
There's more…
See also
Persisting data with Redis
Getting ready
How to do it…
How it works…
There's more…
See also
Persisting data with LevelDB
Getting ready
How to do it…
How it works…
There's more…
See also
Chapter 8: Testing with Node.js
Technical requirements
Testing with tape
Getting ready
How to do it
How it works
See also
Testing with Mocha
Getting ready
How to do it
How it works
There's more
See also
Testing with Jest
Getting ready
How to do it
How it works
There's more
See also
Stubbing HTTP requests
Getting ready
How to do it
How it works
See also
Using Puppeteer
Getting ready
How to do it
How it works
There's more
See also
Configuring Continuous Integration tests
Getting ready
How to do it
How it works
There's more
See also
Chapter 9: Securing Node.js Applications
Technical requirements
Detecting known dependency vulnerabilities
Getting ready
How to do it…
How it works…
See also
Authentication with Express.js
Getting ready
How to do it…
How it works…
There's more…
See also
Setting HTTP headers with Helmet
Getting ready
How to do it…
How it works…
There's more…
See also
Protecting against HTTP parameter pollution attacks
Getting ready
How to do it…
How it works…
There's more…
See also
Preventing JSON pollution
Getting ready
How to do it…
How it works…
See also
Preventing cross-site scripting attacks
Getting ready
How to do it…
How it works…
There's more…
See also
Guarding against cross-site request forgery attacks
Getting ready
How to do it…
How it works…
There's more…
See also
Chapter 10: Performance Optimization
Technical requirements
Benchmarking HTTP requests
Getting ready
How to do it…
How it works…
There's more…
See also
Interpreting flame graphs
Getting ready
How to do it…
How it works…
There's more…
See also
Detecting memory leaks
Getting ready
How to do it…
How it works…
There's more…
See also
Optimizing synchronous functions
Getting ready
How to do it…
How it works…
See also
Optimizing asynchronous functions
Getting ready
How to do it…
How it works…
See also
Working with worker threads
Getting ready
How to do it…
How it works…
Chapter 11: Deploying Node.js Microservices
Technical requirements
Generating a microservice with LoopBack
Getting ready
How to do it…
How it works…
There's more…
See also
Consuming a microservice
Getting ready
How to do it…
How it works…
See also
Handling errors
Getting ready
How to do it…
How it works…
There's more…
See also
Building a Docker container
Getting ready
How to do it…
How it works…
There's more…
See also
Publishing a Docker image
Getting ready
How to do it…
How it works…
There's more…
See also
Deploying to Kubernetes
Getting ready
How to do it…
How it works…
There's more…
See also
Chapter 12: Debugging Node.js
Technical requirements
Diagnosing issues with Chrome DevTools
Getting ready
How to do it
How it works
There's more
See also
Logging with Node.js
Getting ready
How to do it
How it works
There's more
See also
Enabling debug logs
Getting ready
How to do it
How it works
There's more
See also
Enabling Node.js core debug logs
Getting ready
How to do it
How it works
See also
Increasing stack trace size
Getting ready
How to do it
How it works
There's more
See also
Creating diagnostic reports
Getting ready
How to do it
How it works
See also
Other Books You May Enjoy
Index

Node Cookbook [4 ed.]
 9781838558758, 1838558756

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up