SlideShare ist ein Scribd-Unternehmen logo
Node.js Firebase
Jul 23, 2023
Node.js
Hello!
Brion Silva
Associate Technical Lead
brion@wso2.com
What is 🤔
4
RUNTIME
5
Created by RYAN DAHL in 2009
Allows to execute Javascript outside the
browser
Enables developers to write a full stack
application in JavaScript
Uses an event-driven, non-blocking I/O event
loop for handling concurrent requests.
Comes with a built in package manager.
Built on top of Chrome V8 Engine
Open Source & Cross Platform Fast & Efficient
󰞐 Source : https://github.com/nodejs/node
⬇ Download: https://nodejs.org/en/download/current
What’s
What is npm?
● npm is Node.js's package manager.
● It manages dependencies in Node.js projects.
● Developers can install open-source packages with ease.
● npm simplifies adding functionality to Node.js apps.
● It ensures version control for package consistency.
7
What’s Event Loop?
What is Event Loop?
9
1st PRIORITY - Call Stack
➡ Handles Synchronous Code
2nd PRIORITY - MICROTASK QUEUE
➡ Handles Promises and Microtasks
3rd PRIORITY - TASK QUEUE
➡ Handles Callbacks (From DOM
APIs, I/O operations, Timers, etc.)
RESTful API Development with Node.js
What is a RESTful API?
11
API: Application Programming Interface
REST: Representational State Transfer
✅ STANDARDIZED
✅ STATELESS
✅ PERFORMANT
REQUEST vs RESPONSE
12
HTTP Methods
13
CREATE
READ
UPDATE
DELETE
POST
GET
PUT
DELETE
14
Demo
15
Scenario Overview
IDEALIZE
API
Base URL: http://localhost:3000
Endpoints:
http://localhost:3000/authors
http://localhost:3000/sessions
The API should be able to provide the organizing
committee to manage and organize the sessions
organized as prerequisites for IDEALIZE 2023.
Requirements:
⭐ Should be able to fetch, add, update & delete authors.
⭐ Should be able to fetch, add, update & delete sessions.
⭐ Add, update & delete should be protected.
Supporting Software
16
Package Manager - npm
Web Framework - Express.js
Database System - Firestore
REST Client - Postman
💡Can also use yarn or pnpm as well.
💡Can also use Nest, Sails, Koa, etc.
💡Can also use MySQL, MongoDB, etc.
💡Can also use Insomnia, curl, etc.
17
🚀 Minimal API: index.js ↗
Structuring the API
Controllers
Modules or functions that handle the business
logic for specific API endpoints.
Routes
HTTP methods that clients can use to interact
with the API.
Middleware
Functions that have access to the request and
response objects and can perform additional
processing before the final request handler
Folder Structure
18
󰞐 Code up to now: source ↗
Firebase
Hello!
Omal Wijegunawardana
Senior Software Engineer
omal@wso2.com
What’s
What is Firebase?
● Firebase in NOT a database.
● A collection of backend cloud computing services by Google.
● There is a free tier to try out things.
● It offers following services (and more)
⦿ Databases
⦿ Authentication
⦿ Storage
⦿ Hosting
⦿ Compute units
⦿ Analytics
22
What’s
What is Cloud Firestore?
● NoSQL cloud database
● Collection/Document structure of data
● Store data in flexible, hierarchical data structures
● Integrate with web or mobile technologies with provided SDKs
● Realtime updates
● Offline support
● Scales automatically
24
25
Demo
26
What’s next?
● Use an IDaaS like Asgardeo to Authorize users accessing your API.
⦿ https://wso2.com/asgardeo
● Consuming configurations from .env files.
⦿ Do not push the original file to the repository.
⦿ Push a .env.sample file with placeholders.
● Use a logger for logging in useful actions that’ll come in handy for debugging.
⦿ https://www.npmjs.com/package/winston
● You may have to use additional tools.
⦿ `cors`
⦾ Handle cross origin requests when embedding the API in to a web application.
⦿ `dotenv`
⦾ Read environment variables from .env files.
Question Time!
wso2.com
Thanks!

Weitere ähnliche Inhalte

Ähnlich wie IDEALIZE 2023 - NodeJS & Firebase Session

Building a Distributed & Automated Open Source Program at Netflix
Building a Distributed & Automated Open Source Program at NetflixBuilding a Distributed & Automated Open Source Program at Netflix
Building a Distributed & Automated Open Source Program at Netflix
All Things Open
 
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud EnvironmentsTools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
VMware Tanzu
 
What is Google Cloud Platform - GDG DevFest 18 Depok
What is Google Cloud Platform - GDG DevFest 18 DepokWhat is Google Cloud Platform - GDG DevFest 18 Depok
What is Google Cloud Platform - GDG DevFest 18 Depok
Imre Nagi
 
Wie macht man aus Software einen Online-Service in der Cloud
Wie macht man aus Software einen Online-Service in der CloudWie macht man aus Software einen Online-Service in der Cloud
Wie macht man aus Software einen Online-Service in der Cloud
Aarno Aukia
 
Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015
Microsoft
 
Top 13 Backend Frameworks for Web development in 2024
Top 13 Backend Frameworks for Web development in 2024Top 13 Backend Frameworks for Web development in 2024
Top 13 Backend Frameworks for Web development in 2024
Clarion Technologies
 
Gdsc muk - innocent
Gdsc   muk - innocentGdsc   muk - innocent
Gdsc muk - innocent
junaidhasan17
 
Top 11 Front-End Web Development Tools To Consider in 2020
 Top 11 Front-End Web Development Tools To Consider in 2020 Top 11 Front-End Web Development Tools To Consider in 2020
Top 11 Front-End Web Development Tools To Consider in 2020
Katy Slemon
 
InterCon 2016 - SLA vs Agilidade: uso de microserviços e monitoramento de cloud
InterCon 2016 - SLA vs Agilidade: uso de microserviços e monitoramento de cloudInterCon 2016 - SLA vs Agilidade: uso de microserviços e monitoramento de cloud
InterCon 2016 - SLA vs Agilidade: uso de microserviços e monitoramento de cloud
iMasters
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
Arjun Sreekumar
 
Important Backend Frameworks To Remember For Businesses In 2023
Important Backend Frameworks To Remember For Businesses In 2023Important Backend Frameworks To Remember For Businesses In 2023
Important Backend Frameworks To Remember For Businesses In 2023
Netizens Technologies
 
Industrial Training.pptx
Industrial Training.pptxIndustrial Training.pptx
Industrial Training.pptx
SamraatBansal1
 
Understanding Node.js and Django.docx
Understanding Node.js and Django.docxUnderstanding Node.js and Django.docx
Understanding Node.js and Django.docx
Savior_Marketing
 
Red Hat Java Update and Quarkus Introduction
Red Hat Java Update and Quarkus IntroductionRed Hat Java Update and Quarkus Introduction
Red Hat Java Update and Quarkus Introduction
John Archer
 
Exploring Next Generation Buildpacks - Anand Rao & Scott Deeg
Exploring Next Generation Buildpacks - Anand Rao & Scott DeegExploring Next Generation Buildpacks - Anand Rao & Scott Deeg
Exploring Next Generation Buildpacks - Anand Rao & Scott Deeg
VMware Tanzu
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
kloia
 
Nodejs framework for app development.pdf
Nodejs framework for app development.pdfNodejs framework for app development.pdf
Nodejs framework for app development.pdf
Sufalam Technologies
 
NodeJS VS Python
NodeJS VS PythonNodeJS VS Python
NodeJS VS Python
Krishang Technolab
 
Joseph Ardolino CV (1)
Joseph Ardolino CV (1)Joseph Ardolino CV (1)
Joseph Ardolino CV (1)
Joe Ardolino
 
Mastinder singh visualcv_resume
Mastinder singh visualcv_resumeMastinder singh visualcv_resume
Mastinder singh visualcv_resume
Mastinder Singh
 

Ähnlich wie IDEALIZE 2023 - NodeJS & Firebase Session (20)

Building a Distributed & Automated Open Source Program at Netflix
Building a Distributed & Automated Open Source Program at NetflixBuilding a Distributed & Automated Open Source Program at Netflix
Building a Distributed & Automated Open Source Program at Netflix
 
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud EnvironmentsTools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
 
What is Google Cloud Platform - GDG DevFest 18 Depok
What is Google Cloud Platform - GDG DevFest 18 DepokWhat is Google Cloud Platform - GDG DevFest 18 Depok
What is Google Cloud Platform - GDG DevFest 18 Depok
 
Wie macht man aus Software einen Online-Service in der Cloud
Wie macht man aus Software einen Online-Service in der CloudWie macht man aus Software einen Online-Service in der Cloud
Wie macht man aus Software einen Online-Service in der Cloud
 
Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015
 
Top 13 Backend Frameworks for Web development in 2024
Top 13 Backend Frameworks for Web development in 2024Top 13 Backend Frameworks for Web development in 2024
Top 13 Backend Frameworks for Web development in 2024
 
Gdsc muk - innocent
Gdsc   muk - innocentGdsc   muk - innocent
Gdsc muk - innocent
 
Top 11 Front-End Web Development Tools To Consider in 2020
 Top 11 Front-End Web Development Tools To Consider in 2020 Top 11 Front-End Web Development Tools To Consider in 2020
Top 11 Front-End Web Development Tools To Consider in 2020
 
InterCon 2016 - SLA vs Agilidade: uso de microserviços e monitoramento de cloud
InterCon 2016 - SLA vs Agilidade: uso de microserviços e monitoramento de cloudInterCon 2016 - SLA vs Agilidade: uso de microserviços e monitoramento de cloud
InterCon 2016 - SLA vs Agilidade: uso de microserviços e monitoramento de cloud
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
Important Backend Frameworks To Remember For Businesses In 2023
Important Backend Frameworks To Remember For Businesses In 2023Important Backend Frameworks To Remember For Businesses In 2023
Important Backend Frameworks To Remember For Businesses In 2023
 
Industrial Training.pptx
Industrial Training.pptxIndustrial Training.pptx
Industrial Training.pptx
 
Understanding Node.js and Django.docx
Understanding Node.js and Django.docxUnderstanding Node.js and Django.docx
Understanding Node.js and Django.docx
 
Red Hat Java Update and Quarkus Introduction
Red Hat Java Update and Quarkus IntroductionRed Hat Java Update and Quarkus Introduction
Red Hat Java Update and Quarkus Introduction
 
Exploring Next Generation Buildpacks - Anand Rao & Scott Deeg
Exploring Next Generation Buildpacks - Anand Rao & Scott DeegExploring Next Generation Buildpacks - Anand Rao & Scott Deeg
Exploring Next Generation Buildpacks - Anand Rao & Scott Deeg
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 
Nodejs framework for app development.pdf
Nodejs framework for app development.pdfNodejs framework for app development.pdf
Nodejs framework for app development.pdf
 
NodeJS VS Python
NodeJS VS PythonNodeJS VS Python
NodeJS VS Python
 
Joseph Ardolino CV (1)
Joseph Ardolino CV (1)Joseph Ardolino CV (1)
Joseph Ardolino CV (1)
 
Mastinder singh visualcv_resume
Mastinder singh visualcv_resumeMastinder singh visualcv_resume
Mastinder singh visualcv_resume
 

Kürzlich hochgeladen

22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
architagupta876
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
Roger Rozario
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
MiscAnnoy1
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
Madan Karki
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
LAXMAREDDY22
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
Madan Karki
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 

Kürzlich hochgeladen (20)

22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 

IDEALIZE 2023 - NodeJS & Firebase Session

  • 5. RUNTIME 5 Created by RYAN DAHL in 2009 Allows to execute Javascript outside the browser Enables developers to write a full stack application in JavaScript Uses an event-driven, non-blocking I/O event loop for handling concurrent requests. Comes with a built in package manager. Built on top of Chrome V8 Engine Open Source & Cross Platform Fast & Efficient 󰞐 Source : https://github.com/nodejs/node ⬇ Download: https://nodejs.org/en/download/current
  • 7. What is npm? ● npm is Node.js's package manager. ● It manages dependencies in Node.js projects. ● Developers can install open-source packages with ease. ● npm simplifies adding functionality to Node.js apps. ● It ensures version control for package consistency. 7
  • 9. What is Event Loop? 9 1st PRIORITY - Call Stack ➡ Handles Synchronous Code 2nd PRIORITY - MICROTASK QUEUE ➡ Handles Promises and Microtasks 3rd PRIORITY - TASK QUEUE ➡ Handles Callbacks (From DOM APIs, I/O operations, Timers, etc.)
  • 10. RESTful API Development with Node.js
  • 11. What is a RESTful API? 11 API: Application Programming Interface REST: Representational State Transfer ✅ STANDARDIZED ✅ STATELESS ✅ PERFORMANT
  • 15. 15 Scenario Overview IDEALIZE API Base URL: http://localhost:3000 Endpoints: http://localhost:3000/authors http://localhost:3000/sessions The API should be able to provide the organizing committee to manage and organize the sessions organized as prerequisites for IDEALIZE 2023. Requirements: ⭐ Should be able to fetch, add, update & delete authors. ⭐ Should be able to fetch, add, update & delete sessions. ⭐ Add, update & delete should be protected.
  • 16. Supporting Software 16 Package Manager - npm Web Framework - Express.js Database System - Firestore REST Client - Postman 💡Can also use yarn or pnpm as well. 💡Can also use Nest, Sails, Koa, etc. 💡Can also use MySQL, MongoDB, etc. 💡Can also use Insomnia, curl, etc.
  • 17. 17 🚀 Minimal API: index.js ↗ Structuring the API Controllers Modules or functions that handle the business logic for specific API endpoints. Routes HTTP methods that clients can use to interact with the API. Middleware Functions that have access to the request and response objects and can perform additional processing before the final request handler Folder Structure
  • 18. 18 󰞐 Code up to now: source ↗
  • 22. What is Firebase? ● Firebase in NOT a database. ● A collection of backend cloud computing services by Google. ● There is a free tier to try out things. ● It offers following services (and more) ⦿ Databases ⦿ Authentication ⦿ Storage ⦿ Hosting ⦿ Compute units ⦿ Analytics 22
  • 24. What is Cloud Firestore? ● NoSQL cloud database ● Collection/Document structure of data ● Store data in flexible, hierarchical data structures ● Integrate with web or mobile technologies with provided SDKs ● Realtime updates ● Offline support ● Scales automatically 24
  • 26. 26 What’s next? ● Use an IDaaS like Asgardeo to Authorize users accessing your API. ⦿ https://wso2.com/asgardeo ● Consuming configurations from .env files. ⦿ Do not push the original file to the repository. ⦿ Push a .env.sample file with placeholders. ● Use a logger for logging in useful actions that’ll come in handy for debugging. ⦿ https://www.npmjs.com/package/winston ● You may have to use additional tools. ⦿ `cors` ⦾ Handle cross origin requests when embedding the API in to a web application. ⦿ `dotenv` ⦾ Read environment variables from .env files.