SlideShare una empresa de Scribd logo
1 de 28
Descargar para leer sin conexión
API Driven Applications
AngularJS, NodeJS and MongoDB
@HmidiHamdi
Software Engeneering | ISSATSo
Member & Founder | ISSATSo Google Club
CXO | OMNIA
Agenda
- API Driven Application
- Basics Of Node JS
- Discovering MongoDB
API DRIVEN APPLICATION
REST API
REST = Representation State Transfer.
- Client Sends HTTP verbs(GET, POST,
DELETE, PUT) along with a URL and
variable parameters that are unlencoded.
- The URL tells us what object to act on.
- Server Replies with a result code and valid
JSON.
HTTP Verbs - CRUD
- GET : when a client want to read an object.
- POST : when a client want to ceate an
object.
- PUT : when a client want to update an
object.
- DELETE : when a client want to delete an
object.
Why REST API ?
a simple way to create a data service enabling
you to easy create all your other applications:
- HTML5 / JAVASCRIPT.
- ANDROID.
- IOS.
MEAN STACK
M : MongoDB (Most Popular NoSql DataBase).
E : ExpressJS (Web Application Framework).
A : AngularJS (A Robust Framework for
creating HTML5 and Javascript rich web
Applications).
N : NodeJS (Server-side Javascript interpreter).
What is NodeJS ?
● Open Source, Cross-platform runtime
environment for server-side and networking
applications.
● NodeJS provides an Event-Driven
architecture and non-blocking I/O API.
● Run your Javascript on Server.
● Uses V8 Engine.
Getting Started with Nodejs
- Install / Build Nodejs
- Type your Script
- open Terminal and run script using :
“node filename.js”
What can you do with NodeJS
- You can create an HTTP server and print ‘hello world’ on the browser in
just 4 lines of JavaScript.
- You can create a DNS server.
- You can create a Static File Server.
- You can create a Web Chat Application like GTalk in the browser.
- Node.js can also be used for creating online games, collaboration tools or
anything which sends updates to the user in real-time.
Hello Node JS
//On inclus la librairie http qui permet la création d'un serveur http basique
var http = require('http');
http.createServer( function (request, response) {
//Le type de contenu sera HTML, le code de réponse 200 (page correctement chargée)
response.writeHead(200, {'Content-Type': 'text/html'});
response.end('Hello <a href="http://www.google.com.fr”>World</a> :pn');
} ).listen(666);
//On affiche un petit message dans la console histoire d'être sûr que le serveur est lancé
console.log('Visit http://localhost:666 ');
Node Package Manager
Express JS
Uses
app.use(express.static(__dirname + '/Public'));
// set the static files location /public/img will be /img for users
app.use(morgan('dev'));
// log every request to the console
app.use(bodyParser.urlencoded({'extended':'true'}));
// parse application/x-www-form-urlencoded
app.use(bodyParser.json());
// parse application/json
app.use(bodyParser.json({ type: 'application/vnd.api+json' }));
// parse application/vnd.api+json as json
app.use(methodOverride());
Routes
app.get('/todos/:id', function (req, res, next) {
var todo=getTodo(id);
res.json(todo);
});
-------------
app.get('/todos', function (req, res, next) {
var todos= getTodos();
res.json(todos);
});
What is MongoDB?
MongoDB is an Open-Source document-
oriented NoSQL database. It stores data in
JSON-like format.
Why use MongoDB ?
- SQL databases was invented to store data.
- MongoDB stores documents (or) Objects.
- now-a-days, everyone works with Objects
(Python/Ruby/Java/etc).
- And we need Databases to persist our objects.
- why not store objects directly?
- Embedded documents and arrays reduce need for Join.
MongoDB Tools
● Mongo : MongoDB client as a Javascript
shell.
● MongoImport : import CSV, JSON and TSV
data.
● MongoExport : export data as JSON and
CSV.
NoSQL DataBase Terms:
DataBase : Like other Relational DataBases.
Collection : Like Table in RDBMS(Has no
common Schema).
Document : Like a Record in RDBMS or Row.
Field : Like a RDBMS column {key : value }.
Mongoose CRUD(Create, Read, Update,
Delete)
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/MyApp');
var SpeakerSchema = new mongoose.Schema({
name : String ,
img : String,
detail : String
});
var Speaker = mongoose.model('Speaker',SpeakerSchema);
Create
app.post('/NewSpeaker',function(req,res){
var sp = new Speaker({
name : req.body.nameS,
img : req.body.imgS,
detail: req.body.det
});
sp.save(function(err){
if(err)
console.log(err);
else
res.json(sp);
});
});
Read
app.get('/getSpeakers/:Name',function(req,res){
Speaker.findOne({ name: req.params.Name }, function (err, doc){
if (err){
res.send(err);
}
res.json(doc);
});
});
app.get('/getSpeakers',function(req,res){
Speaker.find(function(err, todos) {
if (err){
res.send(err);
}
res.json(todos); // return all todos in JSON format
});
});
Update
● Model.update(conditions, update, [options],
[callback])
Delete
● Model.remove(conditions, [callback])
app.delete('/DeleteSpeaker/:id',function(req,res){
Speaker.remove({ _id : req.params.id}, function (err) {
if (err) return res.send(err);
res.json({"result":"success"});
});
});
<Coding Time !>
<Thank You!>
Hmidihamdi7@gmail.com
/+ HamdiHmidiigcien
/hamdi.igc

Más contenido relacionado

La actualidad más candente

Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
Adventures in Multithreaded Core Data
Adventures in Multithreaded Core DataAdventures in Multithreaded Core Data
Adventures in Multithreaded Core Data
Inferis
 

La actualidad más candente (20)

3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't3 Things Everyone Knows About Node JS That You Don't
3 Things Everyone Knows About Node JS That You Don't
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.js
 
Node js getting started
Node js getting startedNode js getting started
Node js getting started
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Analyse Yourself
Analyse YourselfAnalyse Yourself
Analyse Yourself
 
Rest api with node js and express
Rest api with node js and expressRest api with node js and express
Rest api with node js and express
 
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.jsThe MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
 
Getting started with node.js
Getting started with node.jsGetting started with node.js
Getting started with node.js
 
Web Development with NodeJS
Web Development with NodeJSWeb Development with NodeJS
Web Development with NodeJS
 
Web Development with AngularJS, NodeJS and ExpressJS
Web Development with AngularJS, NodeJS and ExpressJSWeb Development with AngularJS, NodeJS and ExpressJS
Web Development with AngularJS, NodeJS and ExpressJS
 
Node.js concurrency
Node.js concurrencyNode.js concurrency
Node.js concurrency
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSockets
 
Preparing your web services for Android and your Android app for web services...
Preparing your web services for Android and your Android app for web services...Preparing your web services for Android and your Android app for web services...
Preparing your web services for Android and your Android app for web services...
 
Introduction about-ajax-framework
Introduction about-ajax-frameworkIntroduction about-ajax-framework
Introduction about-ajax-framework
 
Future-proof Development for Classic SharePoint
Future-proof Development for Classic SharePointFuture-proof Development for Classic SharePoint
Future-proof Development for Classic SharePoint
 
ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!
 
Nodejs vs php_apache
Nodejs vs php_apacheNodejs vs php_apache
Nodejs vs php_apache
 
Adventures in Multithreaded Core Data
Adventures in Multithreaded Core DataAdventures in Multithreaded Core Data
Adventures in Multithreaded Core Data
 
Why and How to Use Virtual DOM
Why and How to Use Virtual DOMWhy and How to Use Virtual DOM
Why and How to Use Virtual DOM
 

Destacado

Alla scoperta di Marte
Alla scoperta di MarteAlla scoperta di Marte
Alla scoperta di Marte
chreact
 
Евгений Собин, Что необходимо знать при организации детского КВН… и любого де...
Евгений Собин, Что необходимо знать при организации детского КВН… и любого де...Евгений Собин, Что необходимо знать при организации детского КВН… и любого де...
Евгений Собин, Что необходимо знать при организации детского КВН… и любого де...
lashkova
 
бойко вера. работа со спонсорами, превосходя все ожидания
бойко вера. работа со спонсорами, превосходя все ожиданиябойко вера. работа со спонсорами, превосходя все ожидания
бойко вера. работа со спонсорами, превосходя все ожидания
lashkova
 
шинкаревская
шинкаревскаяшинкаревская
шинкаревская
lashkova
 
CharityVillageAssessmentReport
CharityVillageAssessmentReportCharityVillageAssessmentReport
CharityVillageAssessmentReport
Digital Systems
 
Resume and cover letter of Muhammad Mollah
Resume and cover letter of Muhammad MollahResume and cover letter of Muhammad Mollah
Resume and cover letter of Muhammad Mollah
Digital Systems
 

Destacado (20)

Alla scoperta di Marte
Alla scoperta di MarteAlla scoperta di Marte
Alla scoperta di Marte
 
Veggie market rei
Veggie market reiVeggie market rei
Veggie market rei
 
Mars-Rover
Mars-RoverMars-Rover
Mars-Rover
 
THE FRUIT
THE FRUITTHE FRUIT
THE FRUIT
 
Евгений Собин, Что необходимо знать при организации детского КВН… и любого де...
Евгений Собин, Что необходимо знать при организации детского КВН… и любого де...Евгений Собин, Что необходимо знать при организации детского КВН… и любого де...
Евгений Собин, Что необходимо знать при организации детского КВН… и любого де...
 
THE FRUITS
THE FRUITSTHE FRUITS
THE FRUITS
 
Joomla! based website redesign project by Digital Systems
Joomla! based website redesign project by Digital SystemsJoomla! based website redesign project by Digital Systems
Joomla! based website redesign project by Digital Systems
 
бойко вера. работа со спонсорами, превосходя все ожидания
бойко вера. работа со спонсорами, превосходя все ожиданиябойко вера. работа со спонсорами, превосходя все ожидания
бойко вера. работа со спонсорами, превосходя все ожидания
 
шинкаревская
шинкаревскаяшинкаревская
шинкаревская
 
Ng-init
Ng-init Ng-init
Ng-init
 
The color of green energy
The color of green energyThe color of green energy
The color of green energy
 
Cosa ci dicono le particelle "strane"?
Cosa ci dicono le particelle "strane"?Cosa ci dicono le particelle "strane"?
Cosa ci dicono le particelle "strane"?
 
Ng-init
Ng-init Ng-init
Ng-init
 
CharityVillageAssessmentReport
CharityVillageAssessmentReportCharityVillageAssessmentReport
CharityVillageAssessmentReport
 
Resume and cover letter of Muhammad Mollah
Resume and cover letter of Muhammad MollahResume and cover letter of Muhammad Mollah
Resume and cover letter of Muhammad Mollah
 
l calore del colore
l calore del colore l calore del colore
l calore del colore
 
Pericoli dallo spazio
Pericoli dallo spazioPericoli dallo spazio
Pericoli dallo spazio
 
Twitter bootstrap | JCertif Tunisie
Twitter bootstrap | JCertif Tunisie Twitter bootstrap | JCertif Tunisie
Twitter bootstrap | JCertif Tunisie
 
Brand promotion strategy for Sellers - Lamido VN
Brand promotion strategy for Sellers - Lamido VNBrand promotion strategy for Sellers - Lamido VN
Brand promotion strategy for Sellers - Lamido VN
 
Ng init
Ng initNg init
Ng init
 

Similar a Getting started with node JS

An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.js
Ayush Mishra
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
Rob Davarnia
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
Ran Mizrahi
 
Scalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSScalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JS
Cosmin Mereuta
 

Similar a Getting started with node JS (20)

An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
node js.pptx
node js.pptxnode js.pptx
node js.pptx
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Node.js
Node.jsNode.js
Node.js
 
API Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015
API  Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015 API  Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015
API Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js Tutorial
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Nodejs
NodejsNodejs
Nodejs
 
Scalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JSScalable network applications, event-driven - Node JS
Scalable network applications, event-driven - Node JS
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Proposal
ProposalProposal
Proposal
 
node_js.pptx
node_js.pptxnode_js.pptx
node_js.pptx
 
Nodejs
NodejsNodejs
Nodejs
 

Más de Hamdi Hmidi (7)

Pentaho | Data Integration & Report designer
Pentaho | Data Integration & Report designerPentaho | Data Integration & Report designer
Pentaho | Data Integration & Report designer
 
Javascript - Getting started | DevCom ISITCom
Javascript - Getting started | DevCom ISITComJavascript - Getting started | DevCom ISITCom
Javascript - Getting started | DevCom ISITCom
 
Modern web application devlopment workflow
Modern web application devlopment workflowModern web application devlopment workflow
Modern web application devlopment workflow
 
Les Basiques - Web Développement HTML5, CSS3, JS et PHP
Les Basiques - Web  Développement HTML5, CSS3, JS et PHPLes Basiques - Web  Développement HTML5, CSS3, JS et PHP
Les Basiques - Web Développement HTML5, CSS3, JS et PHP
 
Hybrid Mobile Apps | Ionic & AngularJS
Hybrid Mobile Apps | Ionic & AngularJSHybrid Mobile Apps | Ionic & AngularJS
Hybrid Mobile Apps | Ionic & AngularJS
 
Android initiation
Android initiationAndroid initiation
Android initiation
 
Les Fondamentaux D'Angular JS | Hmidi Hamdi
Les Fondamentaux D'Angular JS | Hmidi HamdiLes Fondamentaux D'Angular JS | Hmidi Hamdi
Les Fondamentaux D'Angular JS | Hmidi Hamdi
 

Último

Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
sexy call girls service in goa
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
Diya Sharma
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
ellan12
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 

Último (20)

𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
 

Getting started with node JS

  • 1. API Driven Applications AngularJS, NodeJS and MongoDB @HmidiHamdi Software Engeneering | ISSATSo Member & Founder | ISSATSo Google Club CXO | OMNIA
  • 2. Agenda - API Driven Application - Basics Of Node JS - Discovering MongoDB
  • 4. REST API REST = Representation State Transfer. - Client Sends HTTP verbs(GET, POST, DELETE, PUT) along with a URL and variable parameters that are unlencoded. - The URL tells us what object to act on. - Server Replies with a result code and valid JSON.
  • 5. HTTP Verbs - CRUD - GET : when a client want to read an object. - POST : when a client want to ceate an object. - PUT : when a client want to update an object. - DELETE : when a client want to delete an object.
  • 6. Why REST API ? a simple way to create a data service enabling you to easy create all your other applications: - HTML5 / JAVASCRIPT. - ANDROID. - IOS.
  • 7. MEAN STACK M : MongoDB (Most Popular NoSql DataBase). E : ExpressJS (Web Application Framework). A : AngularJS (A Robust Framework for creating HTML5 and Javascript rich web Applications). N : NodeJS (Server-side Javascript interpreter).
  • 8.
  • 9. What is NodeJS ? ● Open Source, Cross-platform runtime environment for server-side and networking applications. ● NodeJS provides an Event-Driven architecture and non-blocking I/O API. ● Run your Javascript on Server. ● Uses V8 Engine.
  • 10. Getting Started with Nodejs - Install / Build Nodejs - Type your Script - open Terminal and run script using : “node filename.js”
  • 11. What can you do with NodeJS - You can create an HTTP server and print ‘hello world’ on the browser in just 4 lines of JavaScript. - You can create a DNS server. - You can create a Static File Server. - You can create a Web Chat Application like GTalk in the browser. - Node.js can also be used for creating online games, collaboration tools or anything which sends updates to the user in real-time.
  • 12. Hello Node JS //On inclus la librairie http qui permet la création d'un serveur http basique var http = require('http'); http.createServer( function (request, response) { //Le type de contenu sera HTML, le code de réponse 200 (page correctement chargée) response.writeHead(200, {'Content-Type': 'text/html'}); response.end('Hello <a href="http://www.google.com.fr”>World</a> :pn'); } ).listen(666); //On affiche un petit message dans la console histoire d'être sûr que le serveur est lancé console.log('Visit http://localhost:666 ');
  • 15. Uses app.use(express.static(__dirname + '/Public')); // set the static files location /public/img will be /img for users app.use(morgan('dev')); // log every request to the console app.use(bodyParser.urlencoded({'extended':'true'})); // parse application/x-www-form-urlencoded app.use(bodyParser.json()); // parse application/json app.use(bodyParser.json({ type: 'application/vnd.api+json' })); // parse application/vnd.api+json as json app.use(methodOverride());
  • 16. Routes app.get('/todos/:id', function (req, res, next) { var todo=getTodo(id); res.json(todo); }); ------------- app.get('/todos', function (req, res, next) { var todos= getTodos(); res.json(todos); });
  • 17.
  • 18. What is MongoDB? MongoDB is an Open-Source document- oriented NoSQL database. It stores data in JSON-like format.
  • 19. Why use MongoDB ? - SQL databases was invented to store data. - MongoDB stores documents (or) Objects. - now-a-days, everyone works with Objects (Python/Ruby/Java/etc). - And we need Databases to persist our objects. - why not store objects directly? - Embedded documents and arrays reduce need for Join.
  • 20. MongoDB Tools ● Mongo : MongoDB client as a Javascript shell. ● MongoImport : import CSV, JSON and TSV data. ● MongoExport : export data as JSON and CSV.
  • 21. NoSQL DataBase Terms: DataBase : Like other Relational DataBases. Collection : Like Table in RDBMS(Has no common Schema). Document : Like a Record in RDBMS or Row. Field : Like a RDBMS column {key : value }.
  • 22. Mongoose CRUD(Create, Read, Update, Delete) var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/MyApp'); var SpeakerSchema = new mongoose.Schema({ name : String , img : String, detail : String }); var Speaker = mongoose.model('Speaker',SpeakerSchema);
  • 23. Create app.post('/NewSpeaker',function(req,res){ var sp = new Speaker({ name : req.body.nameS, img : req.body.imgS, detail: req.body.det }); sp.save(function(err){ if(err) console.log(err); else res.json(sp); }); });
  • 24. Read app.get('/getSpeakers/:Name',function(req,res){ Speaker.findOne({ name: req.params.Name }, function (err, doc){ if (err){ res.send(err); } res.json(doc); }); }); app.get('/getSpeakers',function(req,res){ Speaker.find(function(err, todos) { if (err){ res.send(err); } res.json(todos); // return all todos in JSON format }); });
  • 26. Delete ● Model.remove(conditions, [callback]) app.delete('/DeleteSpeaker/:id',function(req,res){ Speaker.remove({ _id : req.params.id}, function (err) { if (err) return res.send(err); res.json({"result":"success"}); }); });