SlideShare une entreprise Scribd logo
1  sur  9
Node.js basics
“a purely evented, non-blocking infrastructure to script highly concurrent programs”
Gergely Nemeth
Users
Gergely Nemeth
● eBay
● LinkedIn
● Yahoo
● Heroku
● Medium
● Yammer
● Trello
● etc...
Why?
Gergely Nemeth
● Uses V8
● Non-blocking
● Event-driven
● CommonJS module format
When to use it?
Gergely Nemeth
● Lots of non-blocking operations
● JSON APIs
● Reuse code across the client and the server
● Shelling out to unix tools
● Streaming data
● Crawling
When to forget it?
LongDatabaseOperation.on(‘finish’, function () {
//won’t be called!
});
while (true) {
//do some stuff
}
Gergely Nemeth
● Computationally heavy applications
When to forget it?
LongDatabaseOperation.on(‘finish’, function () {
//won’t be called!
});
while (true) {
//do some stuff
}
Gergely Nemeth
● Computationally heavy applications
1. All code runs in a single thread
2. Functions listen on events, act and sleep
How?
Gergely Nemeth
● Download from: http://nodejs.org/ (or nvm on unix-based systems)
● Hello world:
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello Worldn");
});
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");
● Run with: node app.js
NPM
Gergely Nemeth
● Node Packaged Modules
● package.json
{
"name": "MyAwesomeApplication",
"version": "0.0.0",
"dependencies": {
"nodemailer": "~0.5.2",
"express": "~3.3.4"
}
}
● npm install
● npm install XX --save
Next...
Gergely Nemeth
● Node.js best practices
● Express, Passport
● Websockets with Socket.io
● MongoDB with Mongoose
● Redis
● Hogan.js (mustache)

Contenu connexe

Tendances

Tendances (20)

Nodejs web service for starters
Nodejs web service for startersNodejs web service for starters
Nodejs web service for starters
 
Node.js with Express
Node.js with ExpressNode.js with Express
Node.js with Express
 
Architecture of web servers
Architecture of web serversArchitecture of web servers
Architecture of web servers
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
 
CQRS and Event Sourcing with PHP
CQRS and Event Sourcing with PHPCQRS and Event Sourcing with PHP
CQRS and Event Sourcing with PHP
 
Neoito — Scaling node.js
Neoito — Scaling node.jsNeoito — Scaling node.js
Neoito — Scaling node.js
 
React web development
React web developmentReact web development
React web development
 
CQRS and Event Sourcing with PHP - shorter version
CQRS and Event Sourcing with PHP - shorter versionCQRS and Event Sourcing with PHP - shorter version
CQRS and Event Sourcing with PHP - shorter version
 
Django introduction by Ssentamu Abel
Django introduction by Ssentamu AbelDjango introduction by Ssentamu Abel
Django introduction by Ssentamu Abel
 
Daniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého SchizmaDaniel Steigerwald - Este.js - konec velkého Schizma
Daniel Steigerwald - Este.js - konec velkého Schizma
 
Using Javascript in today's world
Using Javascript in today's worldUsing Javascript in today's world
Using Javascript in today's world
 
Akademy 2010 presentation
Akademy 2010 presentationAkademy 2010 presentation
Akademy 2010 presentation
 
What is node.js
What is node.jsWhat is node.js
What is node.js
 
Custom angular libraries
Custom angular librariesCustom angular libraries
Custom angular libraries
 
JavaScript Tools and Implementation
JavaScript Tools and ImplementationJavaScript Tools and Implementation
JavaScript Tools and Implementation
 
TypeScript Jump Start
TypeScript Jump StartTypeScript Jump Start
TypeScript Jump Start
 
QtPass and opensource project management, the road from a 2 day project till ...
QtPass and opensource project management, the road from a 2 day project till ...QtPass and opensource project management, the road from a 2 day project till ...
QtPass and opensource project management, the road from a 2 day project till ...
 
Reusability is the goal
Reusability is the goalReusability is the goal
Reusability is the goal
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Mono Repo
Mono RepoMono Repo
Mono Repo
 

Similaire à Node.js basics

Similaire à Node.js basics (20)

An overview of node.js
An overview of node.jsAn overview of node.js
An overview of node.js
 
All Aboard The Stateful Train
All Aboard The Stateful TrainAll Aboard The Stateful Train
All Aboard The Stateful Train
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
Ext GWT - Overview and Implementation Case Study
Ext GWT - Overview and Implementation Case StudyExt GWT - Overview and Implementation Case Study
Ext GWT - Overview and Implementation Case Study
 
Gainesville Web Developer Group, Sept 2012
Gainesville Web Developer Group, Sept 2012Gainesville Web Developer Group, Sept 2012
Gainesville Web Developer Group, Sept 2012
 
Evaluating a password manager
Evaluating a password managerEvaluating a password manager
Evaluating a password manager
 
Node, express & sails
Node, express & sailsNode, express & sails
Node, express & sails
 
Nodejs
NodejsNodejs
Nodejs
 
Electron JS | Build cross-platform desktop applications with web technologies
Electron JS | Build cross-platform desktop applications with web technologiesElectron JS | Build cross-platform desktop applications with web technologies
Electron JS | Build cross-platform desktop applications with web technologies
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
 
Full stack development
Full stack developmentFull stack development
Full stack development
 
Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js Presentation
 
Liferay portals in real projects
Liferay portals  in real projectsLiferay portals  in real projects
Liferay portals in real projects
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJS
 
02 Node introduction
02 Node introduction02 Node introduction
02 Node introduction
 
.Net Architecture and Performance Tuning
.Net Architecture and Performance Tuning.Net Architecture and Performance Tuning
.Net Architecture and Performance Tuning
 
Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Node.js basics

  • 1. Node.js basics “a purely evented, non-blocking infrastructure to script highly concurrent programs” Gergely Nemeth
  • 2. Users Gergely Nemeth ● eBay ● LinkedIn ● Yahoo ● Heroku ● Medium ● Yammer ● Trello ● etc...
  • 3. Why? Gergely Nemeth ● Uses V8 ● Non-blocking ● Event-driven ● CommonJS module format
  • 4. When to use it? Gergely Nemeth ● Lots of non-blocking operations ● JSON APIs ● Reuse code across the client and the server ● Shelling out to unix tools ● Streaming data ● Crawling
  • 5. When to forget it? LongDatabaseOperation.on(‘finish’, function () { //won’t be called! }); while (true) { //do some stuff } Gergely Nemeth ● Computationally heavy applications
  • 6. When to forget it? LongDatabaseOperation.on(‘finish’, function () { //won’t be called! }); while (true) { //do some stuff } Gergely Nemeth ● Computationally heavy applications 1. All code runs in a single thread 2. Functions listen on events, act and sleep
  • 7. How? Gergely Nemeth ● Download from: http://nodejs.org/ (or nvm on unix-based systems) ● Hello world: // Load the http module to create an http server. var http = require('http'); // Configure our HTTP server to respond with Hello World to all requests. var server = http.createServer(function (request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.end("Hello Worldn"); }); // Listen on port 8000, IP defaults to 127.0.0.1 server.listen(8000); // Put a friendly message on the terminal console.log("Server running at http://127.0.0.1:8000/"); ● Run with: node app.js
  • 8. NPM Gergely Nemeth ● Node Packaged Modules ● package.json { "name": "MyAwesomeApplication", "version": "0.0.0", "dependencies": { "nodemailer": "~0.5.2", "express": "~3.3.4" } } ● npm install ● npm install XX --save
  • 9. Next... Gergely Nemeth ● Node.js best practices ● Express, Passport ● Websockets with Socket.io ● MongoDB with Mongoose ● Redis ● Hogan.js (mustache)