Share
Embed
Transcript
22 slides
-
About Me Hiren Dave “I am a programmer and I
will not fix your PC” Programmer & Tech Author, Blogger and Speaker Co-Organizer, GDG Ahmedabad, Laravel Live Ahmedabad -
Session Agenda • NodeJS Introduction • Understand NPM and Install
NodeJs • Let’s bust some myths about NodeJs? • What you can build with NodeJs • Hello World NodeJs • Introduction to core modules of NodeJs • Create NodeJS module • API development with NodeJs • NodeJs WebSocket • NodeJs Database Connection • Machine Learning with NodeJs • Q & A -
NodeJs Introduction • NodeJs is open source • It’s cross
platform run time environment • Specifically used for developing server side web applications and Networking Applications • NodeJS uses event driven non blocking I/O model -
Let’s understand Non Blocking I/O Model //Blocking Model console.log(“Prepare to
get data set 1”); fetchDataSet1(params); console.log(“Prepare to get data set 2”) fetchDataSet2(params); console.log(“Prepare to get data set 3”) fetchDataSet3(params); -
Let’s understand Non Blocking I/O Model //How NodeJs Overcome it.
console.log(“Prepare to get data set 1”); fetchDataSet1(params, function(){ console.log(“Data set 1 is available”) }); console.log(“Prepare to get data set 2”) fetchDataSet2(params, function(){ console.log(“Data set 2 is available”) }); console.log(“Prepare to get data set 3”) fetchDataSet3(params, function(){ console.log(“Data set 3 is available”) }); -
Understand NPM and Install NodeJs • NPM is world’s largest
software registry • NPM is free • It’s sole purpose is open source contribution • NPM is part of NodeJS installation Download it from official Website https://nodejs.org -
Understand NPM and Install NodeJs • NPM is world’s largest
software registry • NPM is free • It’s sole purpose is open source contribution • NPM is part of NodeJS installation Download it from official Website https://nodejs.org -
Lets bust some myths about NodeJs • NodeJs can only
be used to make chat applications • NodeJs is not secure • NodeJs is slow • NodeJs is not suitable for making scalable applications -
What you can build with NodeJs • Real time chat
/ network applications • Data (Audio / Video) streaming applications • Applications to handle concurrent requests • APIs for web applications • Microservices • Proxy servers • ML models -
Hello World NodeJs var http = require('http'); http.createServer(function (req, res)
{ res.writeHead(200, {'Content-Type': 'text/html'}); res.end('Hello NodeJs!'); }).listen(8000); -
Introduction to Core Modules of NodeJs • http • fs
• os • path • url -
Create NodeJs Module > mkdir myModule > cd myModule >
npm init -y > nano index.js > node > date = require(./index) -
Api Development NodeJs and Express > mkdir api > cd
api > npm install -g express-generator > npm install express --save > nano index.js -
NodeJs WebSocket > mkdir socket > cd socket > nano
index.js > nano client.js > npm install websocket -
NodeJs Database Connection > mkdir database > cd database >
nano index.js > npm install mysql -
Machine Learning with NodeJs > mkdir ml > cd ml
> nano index.js > npm install @tensorflow/tfjs > npm install @tensorflow/tfjs-node -
Being a NodeJs Developer • Only NodeJs Development • MEAN
Stack (MongoDB + Express + Angular + NodeJs) • MERN Stack (MongoDB + Express + ReactJs + NodeJs) • NodeJS + Serverless (AWS Lambda) -
NodeJs Frameworks • Express • Socket.io • Nest.js • Hapi.js
• Koa.js • Meteor.js • Sails.js • PM2 -
Keep Calm and Code On Thank You Blog : https://hirendave.tech
/ https://hiren.dev Twitter : @hjdave