The Notes for Professionals book is compiled from Stack Overflow Documentation, the content is written by the beautiful people at Stack Overflow. Text content is released under Creative Commons BY-SA. See credits at the end of this book whom contributed to the various chapters. Images may be copyright of their respective owners unless otherwise specified
Book created for educational purposes and is not affiliated with group(s), company(s) nor Stack Overflow. All trademarks belong to their respective company owners
https://goalkicker.com/
Content
1-1
Content list
1-2
About
1-3
Chapter 1: Getting started with Node.js
1-4
Section 1.1: Hello World HTTP server
1-5
Section 1.2: Hello World command line
1-6
Section 1.3: Hello World with Express
1-7
Section 1.4: Installing and Running Node.js
1-8
Section 1.5: Debugging Your NodeJS Application
1-9
Section 1.6: Hello World basic routing
1-10
Section 1.7: Hello World in the REPL
1-11
Section 1.8: Deploying your application online
1-12
Section 1.9: Core modules
1-13
Section 1.10: TLS Socket: server and client
1-14
Section 1.11: How to get a basic HTTPS web server up and running!
1-15
Chapter 2: npm
1-16
Section 2.1: Installing packages
1-17
Section 2.2: Uninstalling packages
1-18
Section 2.3: Setting up a package configuration
1-19
Section 2.4: Running scripts
1-20
Section 2.5: Basic semantic versioning
1-21
Section 2.6: Publishing a package
1-22
Section 2.7: Removing extraneous packages
1-23
Section 2.8: Listing currently installed packages
1-24
Section 2.9: Updating npm and packages
1-25
Section 2.10: Scopes and repositories
1-26
Section 2.11: Linking projects for faster debugging and development
1-27
Section 2.12: Locking modules to specific versions
1-28
Section 2.13: Setting up for globally installed packages
1-29
Chapter 3: Web Apps With Express
1-30
Section 3.1: Getting Started
1-31
Section 3.2: Basic routing
1-32
Section 3.3: Modular express application
1-33
Section 3.4: Using a Template Engine
1-34
Section 3.5: JSON API with ExpressJS
1-35
Section 3.6: Serving static files
1-36
Section 3.7: Adding Middleware
1-37
Section 3.8: Error Handling
1-38
Section 3.9: Getting info from the request
1-39
Section 3.10: Error handling in Express
1-40
Section 3.11: Hook: How to execute code before any req and after any res
1-41
Section 3.12: Setting cookies with cookie-parser
1-42
Section 3.13: Custom middleware in Express
1-43
Section 3.14: Named routes in Django-style
1-44
Section 3.15: Hello World
1-45
Section 3.16: Using middleware and the next callback
1-46
Section 3.17: Error handling
1-47
Section 3.18: Handling POST Requests
1-48
Chapter 4: Filesystem I/O
1-49
Section 4.1: Asynchronously Read from Files
1-50
Section 4.2: Listing Directory Contents with readdir or readdirSync
1-51
Section 4.3: Copying files by piping streams
1-52
Section 4.4: Reading from a file synchronously
1-53
Section 4.5: Check Permissions of a File or Directory
1-54
Section 4.6: Checking if a file or a directory exists
1-55
Section 4.7: Determining the line count of a text file
1-56
Section 4.8: Reading a file line by line
1-57
Section 4.9: Avoiding race conditions when creating or using an existing directory
1-58
Section 4.10: Cloning a file using streams
1-59
Section 4.11: Writing to a file using writeFile or writeFileSync
1-60
Section 4.12: Changing contents of a text file
1-61
Section 4.13: Deleting a file using unlink or unlinkSync
1-62
Section 4.14: Reading a file into a Buer using streams
1-63
Chapter 5: Exporting and Consuming Modules
1-64
Section 5.1: Creating a hello-world.js module
1-65
Section 5.2: Loading and using a module
1-66
Section 5.3: Folder as a module
1-67
Section 5.4: Every module injected only once
1-68
Section 5.5: Module loading from node_modules
1-69
Section 5.6: Building your own modules
1-70
Section 5.7: Invalidating the module cache
1-71
Chapter 6: Exporting and Importing Module in node.js
1-72
Section 6.1: Exporting with ES6 syntax
1-73
Section 6.2: Using a simple module in node.js
1-74
Chapter 7: How modules are loaded
1-75
Section 7.1: Global Mode
1-76
Section 7.2: Loading modules
1-77
Chapter 8: Cluster Module
1-78
Section 8.1: Hello World
1-79
Section 8.2: Cluster Example
1-80
Chapter 9: Readline
1-81
Section 9.1: Line-by-line file reading
1-82
Section 9.2: Prompting user input via CLI
1-83
Chapter 10: package.json
1-84
Section 10.1: Exploring package.json
1-85
Section 10.2: Scripts
1-86
Section 10.3: Basic project definition
1-87
Section 10.4: Dependencies
1-88
Section 10.5: Extended project definition
1-89
Chapter 11: Event Emitters
1-90
Section 11.1: Basics
1-91
Section 11.2: Get the names of the events that are subscribed to
1-92
Section 11.3: HTTP Analytics through an Event Emitter
1-93
Section 11.4: Get the number of listeners registered to listen for a specific event
1-94
Chapter 12: Autoreload on changes
1-95
Section 12.1: Autoreload on source code changes using nodemon
1-96
Section 12.2: Browsersync
1-97
Chapter 13: Environment
1-98
Section 13.1: Accessing environment variables
1-99
Section 13.2: process.argv command line arguments
1-100
Section 13.3: Loading environment properties from a "property file"
1-101
Section 13.4: Using dierent Properties/Configuration for dierent environments like dev, qa, staging etc
1-102
Chapter 14: Callback to Promise
1-103
Section 14.1: Promisifying a callback
1-104
Section 14.2: Manually promisifying a callback
1-105
Section 14.3: setTimeout promisified
1-106
Chapter 15: Executing files or commands with Child Processes
1-107
Section 15.1: Spawning a new process to execute a command
1-108
Section 15.2: Spawning a shell to execute a command
1-109
Section 15.3: Spawning a process to run an executable
1-110
Chapter 16: Exception handling
1-111
Section 16.1: Handling Exception In Node.Js
1-112
Section 16.2: Unhanded Exception Management
1-113
Section 16.3: Errors and Promises
1-114
Chapter 17: Keep a node application constantly running
1-115
Section 17.1: Use PM2 as a process manager
1-116
Section 17.2: Running and stopping a Forever daemon
1-117
Section 17.3: Continuous running with nohup
1-118
Chapter 18: Uninstalling Node.js
1-119
Section 18.1: Completely uninstall Node.js on Mac OSX
1-120
Section 18.2: Uninstall Node.js on Windows
1-121
Chapter 19: nvm - Node Version Manager
1-122
Section 19.1: Install NVM
1-123
Section 19.2: Check NVM version
1-124
Section 19.3: Installing an specific Node version
1-125
Section 19.4: Using an already installed node version
1-126
Section 19.5: Install nvm on Mac OSX
1-127
Section 19.6: Run any arbitrary command in a subshell with the desired version of node
1-128
Section 19.7: Setting alias for node version
1-129
Chapter 20: http
1-130
Section 20.1: http server
1-131
Section 20.2: http client
1-132
Chapter 21: Using Streams
1-133
Section 21.1: Read Data from TextFile with Streams
1-134
Section 21.2: Piping streams
1-135
Section 21.3: Creating your own readable/writable stream
1-136
Section 21.4: Why Streams?
1-137
Chapter 22: Deploying Node.js applications in production
1-138
Section 22.1: Setting NODE_ENV="production"
1-139
Section 22.2: Manage app with process manager
1-140
Section 22.3: Deployment using process manager
1-141
Section 22.4: Deployment using PM2
1-142
Section 22.5: Using dierent Properties/Configuration for dierent environments like dev, qa, staging etc
1-143
Section 22.6: Taking advantage of clusters
1-144
Chapter 23: Securing Node.js applications
1-145
Section 23.1: SSL/TLS in Node.js
1-146
Section 23.2: Preventing Cross Site Request Forgery (CSRF)
1-147
Section 23.3: Setting up an HTTPS server
1-148
Section 23.4: Using HTTPS
1-149
Section 23.5: Secure express.js 3 Application
1-150
Chapter 24: Mongoose Library
1-151
Section 24.1: Connect to MongoDB Using Mongoose
1-152
Section 24.2: Find Data in MongoDB Using Mongoose, Express.js Routes and $text Operator
1-153
Section 24.3: Save Data to MongoDB using Mongoose and Express.js Routes
1-154
Section 24.4: Find Data in MongoDB Using Mongoose and Express.js Routes
1-155
Section 24.5: Useful Mongoose functions
1-156
Section 24.6: Indexes in models
1-157
Section 24.7: find data in mongodb using promises
1-158
Chapter 25: async.js
1-159
Section 25.1: Parallel : multi-tasking
1-160
Section 25.2: async.each(To handle array of data eciently)
1-161
Section 25.3: Series : independent mono-tasking
1-162
Section 25.4: Waterfall : dependent mono-tasking
1-163
Section 25.5: async.times(To handle for loop in better way)
1-164
Section 25.6: async.series(To handle events one by one)
1-165
Chapter 26: File upload
1-166
Section 26.1: Single File Upload using multer
1-167
Section 26.2: Using formidable module
1-168
Chapter 27: Socket.io communication
1-169
Section 27.1: "Hello world!" with socket messages
1-170
Chapter 28: Mongodb integration
1-171
Section 28.1: Simple connect
1-172
Section 28.2: Simple connect, using promises
1-173
Section 28.3: Connect to MongoDB
1-174
Section 28.4: Insert a document
1-175
Section 28.5: Read a collection
1-176
Section 28.6: Update a document
1-177
Section 28.7: Delete a document
1-178
Section 28.8: Delete multiple documents
1-179
Chapter 29: Handling POST request in Node.js
1-180
Section 29.1: Sample node.js server that just handles POST requests
1-181
Chapter 30: Simple REST based CRUD API
1-182
Section 30.1: REST API for CRUD in Express 3+
1-183
Chapter 31: Template frameworks
1-184
Section 31.1: Nunjucks
1-185
Chapter 32: Node.js Architecture & Inner Workings
1-186
Section 32.1: Node.js - under the hood
1-187
Section 32.2: Node.js - in motion
1-188
Chapter 33: Debugging Node.js application
1-189
Section 33.1: Core node.js debugger and node inspector
1-190
Chapter 34: Node server without framework
1-191
Section 34.1: Framework-less node server
1-192
Section 34.2: Overcoming CORS Issues
1-193
Chapter 35: Node.JS with ES6
1-194
Section 35.1: Node ES6 Support and creating a project with Babel
1-195
Section 35.2: Use JS es6 on your NodeJS app
1-196
Chapter 36: Interacting with Console
1-197
Section 36.1: Logging
1-198
Chapter 37: Cassandra Integration
1-199
Section 37.1: Hello world
1-200
Chapter 38: Creating API's with Node.js
1-201
Section 38.1: GET api using Express
1-202
Section 38.2: POST api using Express
1-203
Chapter 39: Graceful Shutdown
1-204
Section 39.1: Graceful Shutdown - SIGTERM
1-205
Chapter 40: Using IISNode to host Node.js Web Apps in IIS
1-206
Section 40.1: Using an IIS Virtual Directory or Nested Application via <appSettings>
1-207
Section 40.2: Getting Started
1-208
Section 40.3: Basic Hello World Example using Express
1-209
Section 40.4: Using Socket.io with IISNode
1-210
Chapter 41: CLI
1-211
Section 41.1: Command Line Options
1-212
Chapter 42: NodeJS Frameworks
1-213
Section 42.1: Web Server Frameworks
1-214
Section 42.2: Command Line Interface Frameworks
1-215
Chapter 43: grunt
1-216
Section 43.1: Introduction To GruntJs
1-217
Section 43.2: Installing gruntplugins
1-218
Chapter 44: Using WebSocket's with Node.JS
1-219
Section 44.1: Installing WebSocket's
1-220
Section 44.2: Adding WebSocket's to your file's
1-221
Section 44.3: Using WebSocket's and WebSocket Server's
1-222
Section 44.4: A Simple WebSocket Server Example
1-223
Chapter 45: metalsmith
1-224
Section 45.1: Build a simple blog
1-225
{{ title }}
1-226
Chapter 46: Parsing command line arguments
1-227
Section 46.1: Passing action (verb) and values
1-228
Section 46.2: Passing boolean switches
1-229
Chapter 47: Client-server communication
1-230
Section 47.1: /w Express, jQuery and Jade
1-231
Chapter 48: Node.js Design Fundamental
1-232
Section 48.1: The Node.js philosophy
1-233
Chapter 49: Connect to Mongodb
1-234
Section 49.1: Simple example to Connect mongoDB from Node.JS
1-235
Section 49.2: Simple way to Connect mongoDB with core Node.JS
1-236
Chapter 50: Performance challenges
1-237
Section 50.1: Processing long running queries with Node
1-238
Chapter 51: Send Web Notification
1-239
Section 51.1: Send Web notification using GCM ( Google Cloud Messaging System)
1-240
Chapter 52: Remote Debugging in Node.JS
1-241
Section 52.1: Use the proxy for debugging via port on Linux
1-242
Section 52.2: NodeJS run configuration
1-243
Section 52.3: IntelliJ/Webstorm Configuration
1-244
Chapter 53: Database (MongoDB with Mongoose)
1-245
Section 53.1: Mongoose connection
1-246
Section 53.2: Model
1-247
Section 53.3: Insert data
1-248
Section 53.4: Read data
1-249
Chapter 54: Good coding style
1-250
Section 54.1: Basic program for signup
1-251
Chapter 55: Restful API Design: Best Practices
1-252
Section 55.1: Error Handling: GET all resources
1-253
Chapter 56: Deliver HTML or any other sort of file
1-254
Section 56.1: Deliver HTML at specified path
1-255
Chapter 57: TCP Sockets
1-256
Section 57.1: A simple TCP server
1-257
Section 57.2: A simple TCP client
1-258
Chapter 58: Hack
1-259
Section 58.1: Add new extensions to require()
1-260
Chapter 59: Bluebird Promises
1-261
Section 59.1: Converting nodeback library to Promises