5. Serverside JS Scripting with Node.js Flashcards
Powerful runtime environment for executing JavaScript code outside of a web browser and it brings JavaScript laguage to the server-side - enabling developers to build scalable, high performance and event-driven applications.
Node.js
Eliminates the need for context switching and enables code reuse between the front-end and back-end resulting in improved productivity and reduced development time.
allows developers to use JS both on the client-side and server-side providing a unified language and ecosystem.
Node.js has a vast and active ecosystem of modules and libraries available through the
Node Package Manager (npm)
NodeJs is particularly well-suited for building
web apps
APIs
real-time apps requiring instant data updates
bidirectional communications like chat apps
multiplayer games
streaming applications like audio or video processing
real-time analytics
microservices
scalable APIs
single-page apps
Internet of Things deployments
Among other things Node.js is a
web server framework
function when called with either read and serve our index.html
generate a 200 success code
or if there is a problem
generate a 500 error code
server
listening port for app and can be any value between 1 and
65535
calls the server function and modifes port number and writes entry to console.log
listen
used within file system to initialize a new Jode.js project and create a package.json
npm init command
File that serves as the manifest for the project and contains metadata and configuration information about the project, its dependencies, scripts and other details
package.json
to add dependencies you can do it manually or use
npm install <package-name></package-name>
Automatically generated by npm when you install dependencies for your project and serves as a lockfile that ensures deterministic and reproducible builds of your project across different environments.
package-lock.json
The package-lock.json file should be included in version control systems so that other developers or deployment environments can reproduce the exact dependency tree and versions used in the project
version control
directory created by npm as a storage location for all the packages and modules our project relies on and it is where you install packages using npm install, the downloaded packages are placed here.
node_modules
creates hierarchical structure in the node_modules directory
reflects dependency tree of your project.
Lightweight and flexible web framework for Node.js for simplifying the development of web applications and APIs and allows developers to easily handle
routing
middleware
HTTP request/response handling
widely used for building scalable and efficient web applications offering a balance between simplicity and powerful functionality for server-side development
Express.js