SlideShare a Scribd company logo
NodeJS: Chapter 1
7 Nov 2020
Agenda
• Introduction
• Install nodejs
• Hello nodejs
• Nodejs module system
• Event loop
• Npm, yarn
• Create a project
• Frameworks
2
Introduction
• Open source, cross browser, runtime environment
• Executes javascript code on the server
• Build backend services
• Highy scalable, data intensive, and real time apps,
NOT for CPU intensive apps
3
Introduction
• Fewer lines, fewer files, fewer developers, more
requests, faster response
• JavaScript everywhere
• Clean, consistent, similar code on FE and BE
• Latest ECMAScript standards
• Many open source libraries
• Asynchronous I/O (unlike asp.net, ruby ...)
4
Introduction
• Who uses Node.js?
• GoDaddy, Groupon, IBM, LinkedIn, Microsoft,
Netflix, PayPal, SAP, Walmart, Yahoo, Amazon
Web Service
5
Introduction
• Browser = JS engine + browser code
• Nodejs = JS engine + C/C++ code
• Javasciprt = a programming language
• Nodejs = a runtime
• Express, Nest etc. = Nodejs Frameworks
6
Install nodejs
https://nodejs.org/en/
7
Hello nodejs
• Demo
8
Nodejs module system
• Module = sub program, packages as a unit
• CommonJS module system
• Each file is a separate module
• Use “require”
• Private & Public
• Module wrapper function
9
Event Loop
10
Call Stack
Event Queue
Some APIs
Npm, Yarn
• Download and manage dependencies
• Also used in frontend javascript projects
• Yarn: an alternative to npm
• Yet another resource negotiator
• Npm: after few years on Node.js
• Yarn (by facebook): to fix performance and security
concerns of npm
• yarn licenses list
• Yarn why package-name
11
Create a project
• Demo
12
Node.js frameworks
• https://nodejs.dev/learn#nodejs-frameworks-and-
tools
13
Next Topics
• Asynchronous Programming
• Some essential core modules
• Testcases in NodeJS
14
Asynchronous Programming
• JavaScript is synchronous by default and is single
threaded.
• Computers are asynchronous .
• Multiple process could be executed at the same
time.
• Normally, programming languages are
synchronous, and some provide a way to manage
asynchronicity, in the language or through
libraries.
15
Asynchronous Programming
• Node.js introduced a non-blocking I/O
environment to extend this concept to file access,
network calls and so on
• There are different ways to achieve asynchronous
programming in node js.
16
Different ways of Asynchronous
Programming
Need of asynchronous -:
Different I/O operations(File read/write,DB
operations,making http calls)
• Callbacks
• Promises
• Async-await
17
Callbacks
A callback is a simple function that's passed as a
value to another function and will only be executed
when the event happens.
(Events could be button click, api call, customized
event)
Demo-
18
Callbacks
• Callbacks are great for simple cases!
• However every callback adds a level of nesting,
and when you have lots of callbacks, the code
starts to be complicated very quickly.
19
Promises
A promise is an object that may produce a single
value some time in the future: either a resolved
value, or a reason that it’s not resolved (e.g., a
network error occurred)
20
Promises
• Once a promise has been called, it will start in
pending state. This means that the caller function
continues the execution, while it waits for the
promise to do its own processing, and give the
caller function some feedback.
Demo-
21
Async-Await
• Promises were introduced to solve the famous
callback hell problem, but they introduced
complexity on their own, and syntax complexity
• They were good primitives around which a better
syntax could be exposed to the developers, so
when the time was right we got async functions.
• They make the code look like it's synchronous, but
it's asynchronous and non-blocking behind the
scenes.
22
Async-Await
Async-
It simply allows us to write promises based code as
if it was synchronous and it checks that we are not
breaking the execution thread. It operates
asynchronously via the event-loop. Async functions
will always return a value. It makes sure that a
promise is returned and if it is not returned then
javascript automatically wraps it in a promise which
is resolved with its value.
23
Some essential core modules
While numerous libraries are available for extending
Node's functionalities, the engine comes with a set
of core modules implementing basic functionalities.
There's currently 34 core modules included in Node.
fs,path,os,events,http
24
fs
The fs module provides a lot of very useful
functionality to access and interact with the file
system.
All methods in this module are async in nature but
we can get sync as well by adding sync.
25
event,http
• The events module provides us the EventEmitter
class, which is key to working with events in Node.
• The http module of Node.js provides useful
functions and classes to build an HTTP server
26
Writing testcases in NodeJS
• Testing is a key element to any application. For
Node.js, the framework available for Testing is
called Jasmine. In early 2000, there was a
framework for testing JavaScript applications
called JsUnit. Later this framework got upgraded
and is now known as Jasmine.
27
Coming Soon…….
• Web-Socket in NodeJS
• Worker Threads
• Cluster mode
28

More Related Content

What's hot (20)

ODP
Node.js architecture (EN)
Timur Shemsedinov
 
PDF
The new Netflix API
Katharina Probst
 
PDF
Microservices with AWS Lambda and the Serverless Framework
Rowell Belen
 
PPTX
Nodejs overview
Nicola Del Gobbo
 
PPT
Scalability using Node.js
ratankadam
 
PDF
Javantura v4 - Self-service app deployment with Kubernetes and OpenShift - Ma...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
2017 Microservices Practitioner Virtual Summit: The Mechanics of Deploying En...
Ambassador Labs
 
PPTX
Dot net platform and dotnet core fundamentals
Lalit Kale
 
PDF
Serverless architecture: introduction & first steps
The Software House
 
PPTX
NetflixOSS for Triangle Devops Oct 2013
aspyker
 
PPTX
5 Popular Choices for NoSQL on a Microsoft Platform - All Things Open - Octob...
Matthew Groves
 
PDF
2016 07 - CloudBridge Python library (XSEDE16)
Enis Afgan
 
PPTX
Serverless
Vishwas N
 
PPTX
Serverless java
Vishwas N
 
PDF
What we do with Go
MarcelLanz
 
PPTX
How to Build Your First Web App in Go
All Things Open
 
PDF
Velocity NYC 2016 - Containers @ Netflix
aspyker
 
PDF
Docker in Production at the Aurora Team
Haufe-Lexware GmbH & Co KG
 
PPTX
CICD Azure DevOps
Sergey Seletsky
 
PDF
DockerCon SF 2015: The Distributed System Toolkit
Docker, Inc.
 
Node.js architecture (EN)
Timur Shemsedinov
 
The new Netflix API
Katharina Probst
 
Microservices with AWS Lambda and the Serverless Framework
Rowell Belen
 
Nodejs overview
Nicola Del Gobbo
 
Scalability using Node.js
ratankadam
 
Javantura v4 - Self-service app deployment with Kubernetes and OpenShift - Ma...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
2017 Microservices Practitioner Virtual Summit: The Mechanics of Deploying En...
Ambassador Labs
 
Dot net platform and dotnet core fundamentals
Lalit Kale
 
Serverless architecture: introduction & first steps
The Software House
 
NetflixOSS for Triangle Devops Oct 2013
aspyker
 
5 Popular Choices for NoSQL on a Microsoft Platform - All Things Open - Octob...
Matthew Groves
 
2016 07 - CloudBridge Python library (XSEDE16)
Enis Afgan
 
Serverless
Vishwas N
 
Serverless java
Vishwas N
 
What we do with Go
MarcelLanz
 
How to Build Your First Web App in Go
All Things Open
 
Velocity NYC 2016 - Containers @ Netflix
aspyker
 
Docker in Production at the Aurora Team
Haufe-Lexware GmbH & Co KG
 
CICD Azure DevOps
Sergey Seletsky
 
DockerCon SF 2015: The Distributed System Toolkit
Docker, Inc.
 

Similar to Node.js Chapter1 (20)

PPTX
Introduction to node.js By Ahmed Assaf
Ahmed Assaf
 
PDF
Introduction to Node.js
Aaron Rosenberg
 
PDF
Nodejs vatsal shah
Vatsal N Shah
 
PPT
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
PPTX
Introducing Node.js in an Oracle technology environment (including hands-on)
Lucas Jellema
 
PPT
18_Node.js.ppt
MaulikShah516542
 
PPTX
Introduction to node.js GDD
Sudar Muthu
 
PPT
18_Node.js.ppt
KhalilSalhi7
 
PDF
540slidesofnodejsbackendhopeitworkforu.pdf
hamzadamani7
 
PDF
NodeJS
Predhin Sapru
 
PPTX
Intro to Node.js (v1)
Chris Cowan
 
PPTX
NodeJS - Server Side JS
Ganesh Kondal
 
PPTX
An overview of node.js
valuebound
 
PPTX
Nodejs getting started
Triet Ho
 
PDF
Node.js for beginner
Sarunyhot Suwannachoti
 
PPTX
Nodejs intro
Ndjido Ardo BAR
 
PDF
Tech io nodejs_20130531_v0.6
Ganesh Kondal
 
PPTX
Node js meetup
Ansuman Roy
 
PDF
NodeJS for Beginner
Apaichon Punopas
 
PPTX
Introduction Node.js
Erik van Appeldoorn
 
Introduction to node.js By Ahmed Assaf
Ahmed Assaf
 
Introduction to Node.js
Aaron Rosenberg
 
Nodejs vatsal shah
Vatsal N Shah
 
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
Introducing Node.js in an Oracle technology environment (including hands-on)
Lucas Jellema
 
18_Node.js.ppt
MaulikShah516542
 
Introduction to node.js GDD
Sudar Muthu
 
18_Node.js.ppt
KhalilSalhi7
 
540slidesofnodejsbackendhopeitworkforu.pdf
hamzadamani7
 
Intro to Node.js (v1)
Chris Cowan
 
NodeJS - Server Side JS
Ganesh Kondal
 
An overview of node.js
valuebound
 
Nodejs getting started
Triet Ho
 
Node.js for beginner
Sarunyhot Suwannachoti
 
Nodejs intro
Ndjido Ardo BAR
 
Tech io nodejs_20130531_v0.6
Ganesh Kondal
 
Node js meetup
Ansuman Roy
 
NodeJS for Beginner
Apaichon Punopas
 
Introduction Node.js
Erik van Appeldoorn
 
Ad

More from Talentica Software (20)

PPTX
Webpack/Parcel: What’s Happening Behind the React App?
Talentica Software
 
PPTX
Typescript: Beginner to Advanced
Talentica Software
 
PDF
Web 3.0
Talentica Software
 
PPTX
Web Performance & Latest in React
Talentica Software
 
PPTX
Nodejs Chapter 3 - Design Pattern
Talentica Software
 
PPTX
Node js Chapter-2
Talentica Software
 
PDF
Micro Frontends
Talentica Software
 
PPTX
Test Policy and Practices
Talentica Software
 
PPTX
Advanced JavaScript
Talentica Software
 
PPTX
Setting Up Development Environment For Google App Engine & Python | Talentica
Talentica Software
 
PPTX
Connected World in android - Local data sharing and service discovery
Talentica Software
 
PPTX
Mobile App Monetization - Ecosystem & Emerging Trends
Talentica Software
 
PPT
Android Media Player Development
Talentica Software
 
PPTX
Cross Platform Mobile Technologies
Talentica Software
 
PPT
Big Data Technologies - Hadoop
Talentica Software
 
PPTX
Big Data – Are You Ready?
Talentica Software
 
PDF
Legacy modernization
Talentica Software
 
PPT
Continous Integration: A Case Study
Talentica Software
 
PPTX
Technology Challenges in Building New Media Applications
Talentica Software
 
Webpack/Parcel: What’s Happening Behind the React App?
Talentica Software
 
Typescript: Beginner to Advanced
Talentica Software
 
Web Performance & Latest in React
Talentica Software
 
Nodejs Chapter 3 - Design Pattern
Talentica Software
 
Node js Chapter-2
Talentica Software
 
Micro Frontends
Talentica Software
 
Test Policy and Practices
Talentica Software
 
Advanced JavaScript
Talentica Software
 
Setting Up Development Environment For Google App Engine & Python | Talentica
Talentica Software
 
Connected World in android - Local data sharing and service discovery
Talentica Software
 
Mobile App Monetization - Ecosystem & Emerging Trends
Talentica Software
 
Android Media Player Development
Talentica Software
 
Cross Platform Mobile Technologies
Talentica Software
 
Big Data Technologies - Hadoop
Talentica Software
 
Big Data – Are You Ready?
Talentica Software
 
Legacy modernization
Talentica Software
 
Continous Integration: A Case Study
Talentica Software
 
Technology Challenges in Building New Media Applications
Talentica Software
 
Ad

Recently uploaded (20)

PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Biography of Daniel Podor.pdf
Daniel Podor
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 

Node.js Chapter1

  • 2. Agenda • Introduction • Install nodejs • Hello nodejs • Nodejs module system • Event loop • Npm, yarn • Create a project • Frameworks 2
  • 3. Introduction • Open source, cross browser, runtime environment • Executes javascript code on the server • Build backend services • Highy scalable, data intensive, and real time apps, NOT for CPU intensive apps 3
  • 4. Introduction • Fewer lines, fewer files, fewer developers, more requests, faster response • JavaScript everywhere • Clean, consistent, similar code on FE and BE • Latest ECMAScript standards • Many open source libraries • Asynchronous I/O (unlike asp.net, ruby ...) 4
  • 5. Introduction • Who uses Node.js? • GoDaddy, Groupon, IBM, LinkedIn, Microsoft, Netflix, PayPal, SAP, Walmart, Yahoo, Amazon Web Service 5
  • 6. Introduction • Browser = JS engine + browser code • Nodejs = JS engine + C/C++ code • Javasciprt = a programming language • Nodejs = a runtime • Express, Nest etc. = Nodejs Frameworks 6
  • 9. Nodejs module system • Module = sub program, packages as a unit • CommonJS module system • Each file is a separate module • Use “require” • Private & Public • Module wrapper function 9
  • 11. Npm, Yarn • Download and manage dependencies • Also used in frontend javascript projects • Yarn: an alternative to npm • Yet another resource negotiator • Npm: after few years on Node.js • Yarn (by facebook): to fix performance and security concerns of npm • yarn licenses list • Yarn why package-name 11
  • 14. Next Topics • Asynchronous Programming • Some essential core modules • Testcases in NodeJS 14
  • 15. Asynchronous Programming • JavaScript is synchronous by default and is single threaded. • Computers are asynchronous . • Multiple process could be executed at the same time. • Normally, programming languages are synchronous, and some provide a way to manage asynchronicity, in the language or through libraries. 15
  • 16. Asynchronous Programming • Node.js introduced a non-blocking I/O environment to extend this concept to file access, network calls and so on • There are different ways to achieve asynchronous programming in node js. 16
  • 17. Different ways of Asynchronous Programming Need of asynchronous -: Different I/O operations(File read/write,DB operations,making http calls) • Callbacks • Promises • Async-await 17
  • 18. Callbacks A callback is a simple function that's passed as a value to another function and will only be executed when the event happens. (Events could be button click, api call, customized event) Demo- 18
  • 19. Callbacks • Callbacks are great for simple cases! • However every callback adds a level of nesting, and when you have lots of callbacks, the code starts to be complicated very quickly. 19
  • 20. Promises A promise is an object that may produce a single value some time in the future: either a resolved value, or a reason that it’s not resolved (e.g., a network error occurred) 20
  • 21. Promises • Once a promise has been called, it will start in pending state. This means that the caller function continues the execution, while it waits for the promise to do its own processing, and give the caller function some feedback. Demo- 21
  • 22. Async-Await • Promises were introduced to solve the famous callback hell problem, but they introduced complexity on their own, and syntax complexity • They were good primitives around which a better syntax could be exposed to the developers, so when the time was right we got async functions. • They make the code look like it's synchronous, but it's asynchronous and non-blocking behind the scenes. 22
  • 23. Async-Await Async- It simply allows us to write promises based code as if it was synchronous and it checks that we are not breaking the execution thread. It operates asynchronously via the event-loop. Async functions will always return a value. It makes sure that a promise is returned and if it is not returned then javascript automatically wraps it in a promise which is resolved with its value. 23
  • 24. Some essential core modules While numerous libraries are available for extending Node's functionalities, the engine comes with a set of core modules implementing basic functionalities. There's currently 34 core modules included in Node. fs,path,os,events,http 24
  • 25. fs The fs module provides a lot of very useful functionality to access and interact with the file system. All methods in this module are async in nature but we can get sync as well by adding sync. 25
  • 26. event,http • The events module provides us the EventEmitter class, which is key to working with events in Node. • The http module of Node.js provides useful functions and classes to build an HTTP server 26
  • 27. Writing testcases in NodeJS • Testing is a key element to any application. For Node.js, the framework available for Testing is called Jasmine. In early 2000, there was a framework for testing JavaScript applications called JsUnit. Later this framework got upgraded and is now known as Jasmine. 27
  • 28. Coming Soon……. • Web-Socket in NodeJS • Worker Threads • Cluster mode 28