Beschreibung
If youre developing server-side JavaScript applications, you need Node.js! Start with the basics of the Node.js environment: installation, application structure, and modules. Then follow detailed code examples to learn about web development using frameworks like Express and Nest. Learn about different approaches to asynchronous programming, including RxJS and data streams. Details on peripheral topics such as testing, security, and performance make this your all-in-one daily reference for Node.js!In this book, youll learn about:a. Getting Started with Node.js Begin your journey with Node.js. Learn about the core components of the environment such as the V8 engine and libraries. Then install Node.js and explore application development tools and the module system. b. Developing Applications Develop web applications by following practical code examples. Set up a web server using HTTP and develop apps step by step using the Express and Nest frameworks. Connect databases, generate interfaces using the REST server and GraphQL, implement command-line tools, handle asynchronous programming, and more. c. Managing ApplicationsManage your Node.js applications from development to deployment. Learn how to use package managers, implement tests, and protect against security threats. Get expert tips on scalability and performance to optimize your apps. Highlights include:1) Installation2) Asynchronous programming3) Application development 4) Modules 5) Express and Nest frameworks6) Template engines 7) Database connectivity 8) Web sockets9) Session handling10) Deployment and operations11) Security 12) Testing, performance, and scalability Highlights: InstallationAsynchronous programmingApplication development Modules Express and Nest.js frameworksTemplate engines Database connectivity Web socketsSession handlingDeployment and operationsSecurity Testing, performance, and scalability
Autorenportrait
Sebastian Springer is a JavaScript engineer at MaibornWolff. In addition to developing and designing both client-side and server-side JavaScript applications, he focuses on imparting knowledge. As a lecturer for JavaScript, a speaker at numerous conferences, and an author, he inspires enthusiasm for professional development with JavaScript. Sebastian was previously a team leader at Mayflower GmbH, one of the premier web development agencies in Germany. He was responsible for project and team management, architecture, and customer care for companies such as Nintendo Europe, Siemens, and others.
Inhalt
... Structure of the Book ... 28
... Downloading the Code Samples ... 29
... Acknowledgments ... 30
1.1 ... The Story of Node.js ... 33
1.2 ... Organization of Node.js ... 37
1.3 ... Versioning of Node.js ... 38
1.4 ... Benefits of Node.js ... 40
1.5 ... Areas of Use for Node.js ... 40
1.6 ... The Core: V8 Engine ... 41
1.7 ... Libraries around the Engine ... 47
1.8 ... Summary ... 53
2.1 ... Installing Packages ... 56
2.2 ... Compiling and Installing ... 68
2.3 ... Node Version Manager ... 71
2.4 ... Node and Docker ... 71
2.5 ... Summary ... 72
3.1 ... Interactive Mode ... 73
3.2 ... The First Application ... 79
3.3 ... Debugging Node.js Applications ... 88
3.4 ... nodemon Development Tool ... 98
3.5 ... Summary ... 99
4.1 ... Modular Structure ... 101
4.2 ... Core Modules ... 103
4.3 ... JavaScript Module Systems ... 121
4.4 ... Creating and Using Your Own Modules ... 124
4.5 ... Summary ... 135
5.1 ... Web Server ... 137
5.2 ... Node.js as HTTP Client ... 164
5.3 ... Secure Communication with HTTPS ... 168
5.4 ... HTTP/2 ... 170
5.5 ... Summary ... 175
6.1 ... Structure ... 177
6.2 ... Installation ... 178
6.3 ... Basic Principles ... 179
6.4 ... Setup ... 181
6.5 ... Movie Database ... 185
6.6 ... Middleware ... 193
6.7 ... Extended Routing: Deleting Data Records ... 199
6.8 ... Creating and Editing Data Records: Body Parser ... 201
6.9 ... Express 5 ... 208
6.10 ... HTTPS and HTTP/2 ... 209
6.11 ... Summary ... 212
7.1 ... Custom Template Engine ... 214
7.2 ... Template Engines in Practice: Pug ... 215
7.3 ... Handlebars ... 229
7.4 ... Summary ... 239
8.1 ... Node.js and Relational Databases ... 242
8.2 ... Node.js and Nonrelational Databases ... 260
8.3 ... Summary ... 272
9.1 ... Passport ... 273
9.2 ... Setup and Configuration ... 274
9.3 ... Logging In to the Application ... 277
9.4 ... Accessing Resources ... 285
9.5 ... Summary ... 294
10.1 ... Introduction to REST and Usage in Web Applications ... 295
10.2 ... Accessing the Application ... 296
10.3 ... Adaptations to the Application Structure ... 297
10.4 ... Read Requests ... 298
10.5 ... Write Requests ... 309
10.6 ... Authentication via JWTs ... 316
10.7 ... OpenAPI Specification: Documentation with Swagger ... 324
10.8 ... Validation ... 329
10.9 ... Summary ... 335
11.1 ... GraphQL Libraries ... 338
11.2 ... Integration with Express ... 339
11.3 ... GraphiQL ... 341
11.4 ... Reading Data via the Interface ... 342
11.5 ... Write Accesses to the GraphQL Interface ... 347
11.6 ... Authentication for the GraphQL Interface ... 353
11.7 ... Summary ... 355
12.1 ... The Sample Application ... 358
12.2 ... Setup ... 358
12.3 ... WebSockets ... 364
12.4 ... Socket.IO ... 377
12.5 ... Summary ... 383
13.1 ... Type Systems for Node.js ... 386
13.2 ... Tools and Configuration ... 392
13.3 ... Basic Principles ... 398
13.4 ... Classes ... 403
13.5 ... Interfaces ... 406
13.6 ... Type Aliases in TypeScript ... 408
13.7 ... Generics ... 409
13.8 ... TypeScript in Use in a Node.js Application ... 410
13.9 ... Summary ... 412
14.1 ... Installation and Getting Started with Nest ... 414
14.2 ... Nest Command-Line Interface ... 416
14.3 ... Structure of the Application ... 419
14.4 ... Modules: Logical Units in the Source Code ... 421
14.5 ... Controllers: Endpoints of an Application ... 423
14.6 ... Providers: Business Logic of the Application ... 428
14.7 ... Accessing Databases ... 432
14.8 ... Documenting the Endpoints with OpenAPI ... 439
14.9 ... Authentication ... 442
14.10 ... Outlook: Testing in Nest ... 449
14.11 ... Summary ... 451
15.1 ... Basic Principles ... 453
15.2 ... Structure of a Command-Line Application ... 456
15.3 ... Accessing Input and Output ... 461
15.4 ... Tools ... 469
15.5 ... Signals ... 476
15.6 ... Exit Codes ... 478
15.7 ... Summary ... 479
16.1 ... Basic Principles of Asynchronous Programming ... 481
16.2 ... Running External Commands Asynchronously ... 486
16.3 ... Creating Node.js Child Processes with fork Method ... 492
16.4 ... The cluster Module ... 496
16.5 ... Worker Threads ... 504
16.6 ... Promises in Node.js ... 507
16.7 ... Async Functions ... 514
16.8 ... Summary ... 517
17.1 ... Basic Principles ... 520
17.2 ... Operators ... 525
17.3 ... Subjects ... 540
17.4 ... Schedulers ... 542
17.5 ... Summary ... 543
18.1 ... Introduction ... 545
18.2 ... Readable Streams ... 548
18.3 ... Writable Streams ... 559
18.4 ... Duplex Streams ... 566
18.5 ... Transform Streams ... 568
18.6 ... Gulp ... 570
18.7 ... Summary ... 572
19.1 ... Synchronous and Asynchronous Functions ... 573
19.2 ... Existence of Files ... 575
19.3 ... Reading Files ... 576
19.4 ... Error Handling ... 582
19.5 ... Writing to Files ... 582
19.6 ... Directory Operations ... 586
19.7 ... Advanced Operations ... 589
19.8 ... Summary ... 594
20.1 ... Unix Sockets ... 596
20.2 ... Windows Pipes ... 602
20.3 ... TCP Sockets ... 603
20.4 ... UDP Sockets ... 610
20.5 ... Summary ... 614
21.1 ... Most Common Operations ... 616
21.2 ... Advanced Operations ... 627
21.3 ... Tools for Node Package Manager ... 634
21.4 ... Yarn ... 637
21.5 ... Summary ... 638
22.1 ... Style Guides ... 642
22.2 ... Linter ... 643
22.3 ... Prettier ... 648
22.4 ... Programming Mistake Detector: Copy/Paste Detector ... 649
22.5 ... Husky ... 652
22.6 ... Summary ... 653
23.1 ... Unit Testing ... 655
23.2 ... Assertion Testing ... 658
23.3 ... Jasmine ... 663
23.4 ... Jest ... 671
23.5 ... Practical Example of Unit Tests with Jest ... 674
23.6 ... Dealing with Dependencies: Mocking ... 679
23.7 ... Summary ... 681
24.1 ... Filter Input and Escape Output ... 684
24.2 ... Protecting the Server ... 686
24.3 ... Node Package Manager Security ... 704
24.4 ... Client Protection ... 707
24.5 ... Summary ... 711
25.1 ... Deployment ... 713
25.2 ... Tool Support ... 720
25.3 ... Scaling ... 721
25.4 ... pm2: Process Management ... 730
25.5 ... Docker ... 730
25.6 ... Summary ... 732
26.1 ... You Aren’t Gonna Need It ... 733
26.2 ... CPU ... 734
26.3 ... Memory ... 741
26.4 ... Network ... 747
26.5 ... Summary ... 751
27.1 ... Basic Principles ... 753
27.2 ... Architecture ... 756
27.3 ... Infrastructure ... 758
27.4 ... Asynchronous Microservice with RabbitMQ ... 759
27.5 ... API Gateway ... 768
27.6 ... Synchronous Microservice with Express ... 780
27.7 ... Summary ... 789
28.1 ... The Ten Things Ryan Dahl Regrets about Node.js ... 791
28.2 ... Installing Deno ... 793
28.3 ... Execution ... 795
28.4 ... Handling Files ... 796
28.5 ... Web Server with Deno ... 803
28.6 ... Module System ... 804
28.7 ... Summary ... 809