SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
Laboratory of Databases and Web
Applications
Web development using
Express, Node, Angular
João Rocha da Silva (FEUP InfoLab, room I123) Contact: joaorosilva@gmail.com
Contents
1. The MEAN Stack
2. NodeJS
High-performance Javascript-based runtime environment
3. ExpressJS
An MVC web applications framework
4. AngularJS
Google framework for client apps in the browser
5. Live coding session + questions
Javascript across the whole stack
Image from https://codegeekk.
wordpress.com/2015/03/07/explore-
mean-stack-at-2015/
NodeJS
NodeJS
● JavaScript “on the server side”
● Built on Google’s Chrome V8 Javascript engine
○ Compiles JavaScript code to native machine code instead of
interpreting in real time
● Vibrant open-source community
○ Huge ecosystem of free libraries
NodeJS (continued)
● Single thread, event-driven
○ Asynchronous, nonblocking I/O (i.e. not blocking the main thread)
○ Numerous & simultaneous I/O operations become faster
● Very low memory consumption vs PHP, for example
○ Single process
○ Many more simultaneous connections per server instance
○ Node sleeps when there is nothing to be done
● Multicore support also available for clusters
In https://nodejs.org/en/about/
http://blog.soulserv.net/tag/node-js-vs-php/
// 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/");
In https://nodejs.org/en/about/
ExpressJS
Image from http://javascript.tutorialhorizon.com/2014/09/19/understanding-expressjs-middleware-with-a-visual-example/
id username firstname surname
1 joao João Rocha
Example: Listing all users
Database table
Route (JS)
GET /users/all ->
function(req,res)
{
//1. Fetch from DB
User.findAll(
…
//2. Render view
res.render(
‘users/all’,
{
users : users
}
);
}
[
{
"id" : 1,
"username" : "joao",
"firstname" : "João",
"surname" : "Rocha"
}
]
<html>
<h1>Viewing users</h1>
<% for (var user in
users… )
{ %>
Username : <%=user.
username%>
First Name:
<%=users.firstname%>
<% } %>
</html>
Model Route View
Client requests http://127.0.0.1:3000/users/all
Return Object array
Database Querying API
Model
instancesModel
Object-Relational Mapping (ORM) for NodeJS
● User “Class”
“One for each DB table”
● Instances
“One for each table row”
Sequelize is a promise-based ORM for Node.js and io.
js. It supports the dialects PostgreSQL, MySQL,
MariaDB, SQLite and MSSQL and features solid
transaction support, relations, read replication and
more.
Sequelize API Docs:
http://docs.sequelizejs.
com/en/latest/api/model/#findalloptions-
promisearrayinstance
Lots of libraries on the ecosystem
Package manager for the web
CSS, JS, HTML, Images...
Bower
Package manager for NodeJS
Libraries
Node Package Manager
AngularJS
AngularJS
● HTML is good for presenting information
○ But NOT good for storing it
● jQuery uses the DOM to store information, and you need to
set and get by element ID (usually)
○ Huge side effects as the code grows and different parts of the web
page are modified at the same time by many events
○ Harder and harder to debug and maintain
● No one likes to maintain spaghetti code...
● Angular separates business logic and data from the
presentation
○ Services and Factories for data access and storage
○ Views for presentation
○ Controllers are the “glue” between data and presentation
○ Routes switch between Views (Single Page Application)
AngularJS (cont’d)
Image from https://www.
mutuallyhuman.
com/blog/2014/05/08/angularjs-
services-and-factories-done-
right/
AngularJS + ExpressJS are good friends
● Excellent for supporting Mobile Apps + Web site
○ Implement a single JSON-based API
○ Consume JSON on mobile devices
○ Same JSON can be used to generate HTML on the client
○ No need to test two separate APIs, because the site itself uses the
“mobile” API
Live coding session
Code for this presentation available at
https://github.com/silvae86/lbaw_2016_tutorial
João Rocha da Silva is just finishing an Informatics
Engineering PhD at FEUP. He specializes on research data
management, applying the latest Semantic Web Technologies
to the adequate preservation and discovery of research
data assets.
He is experienced in many programming languages
(Javascript-Node, PHP with MVC frameworks, Ruby on Rails,
J2EE, etc etc) running on the major operating systems
(everyday Mac user). Regardless of language, he is a
quick learner that can adapt to any new technology
quickly and effectively.

Mais conteúdo relacionado

Mais procurados

3rd Generation Web Application Platforms
3rd Generation Web Application Platforms3rd Generation Web Application Platforms
3rd Generation Web Application PlatformsNaresh Chintalcheru
 
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?Katy Slemon
 
JavaScript on the server - Node.js
JavaScript on the server - Node.jsJavaScript on the server - Node.js
JavaScript on the server - Node.jsRody Middelkoop
 
Introduction to nodejs
Introduction to nodejsIntroduction to nodejs
Introduction to nodejsJames Carr
 
Skillwise Dust JS Template
Skillwise Dust JS TemplateSkillwise Dust JS Template
Skillwise Dust JS TemplateSkillwise Group
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express jsAhmed Assaf
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JSCakra Danu Sedayu
 
Kickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with YeomanKickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with YeomanPatrick Buergin
 
Learn Developing REST API in Node.js using LoopBack Framework
Learn Developing REST API  in Node.js using LoopBack FrameworkLearn Developing REST API  in Node.js using LoopBack Framework
Learn Developing REST API in Node.js using LoopBack FrameworkMarudi Subakti
 
Ng init | EPI Sousse
Ng init | EPI SousseNg init | EPI Sousse
Ng init | EPI SousseHamdi Hmidi
 
Frontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and WorkflowsFrontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and WorkflowsTreasure Data, Inc.
 
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff NorrisRESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norrismfrancis
 
Single Page Apps with Drupal 8
Single Page Apps with Drupal 8Single Page Apps with Drupal 8
Single Page Apps with Drupal 8Chris Tankersley
 
Pre rendering media sites with nuxt.js & netlify
Pre rendering media sites with nuxt.js & netlifyPre rendering media sites with nuxt.js & netlify
Pre rendering media sites with nuxt.js & netlifynuppla
 
Web Services with Objective-C
Web Services with Objective-CWeb Services with Objective-C
Web Services with Objective-CJuio Barros
 
OSGi and Spring Data for simple (Web) Application Development
OSGi and Spring Data  for simple (Web) Application DevelopmentOSGi and Spring Data  for simple (Web) Application Development
OSGi and Spring Data for simple (Web) Application DevelopmentChristian Baranowski
 

Mais procurados (20)

MongoDB
MongoDBMongoDB
MongoDB
 
3rd Generation Web Application Platforms
3rd Generation Web Application Platforms3rd Generation Web Application Platforms
3rd Generation Web Application Platforms
 
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
 
JavaScript on the server - Node.js
JavaScript on the server - Node.jsJavaScript on the server - Node.js
JavaScript on the server - Node.js
 
Node.js Express Framework
Node.js Express FrameworkNode.js Express Framework
Node.js Express Framework
 
Introduction to nodejs
Introduction to nodejsIntroduction to nodejs
Introduction to nodejs
 
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
 
Skillwise Dust JS Template
Skillwise Dust JS TemplateSkillwise Dust JS Template
Skillwise Dust JS Template
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JS
 
Kickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with YeomanKickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with Yeoman
 
Learn Developing REST API in Node.js using LoopBack Framework
Learn Developing REST API  in Node.js using LoopBack FrameworkLearn Developing REST API  in Node.js using LoopBack Framework
Learn Developing REST API in Node.js using LoopBack Framework
 
Ng init | EPI Sousse
Ng init | EPI SousseNg init | EPI Sousse
Ng init | EPI Sousse
 
Frontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and WorkflowsFrontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and Workflows
 
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff NorrisRESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
 
Single Page Apps with Drupal 8
Single Page Apps with Drupal 8Single Page Apps with Drupal 8
Single Page Apps with Drupal 8
 
Pre rendering media sites with nuxt.js & netlify
Pre rendering media sites with nuxt.js & netlifyPre rendering media sites with nuxt.js & netlify
Pre rendering media sites with nuxt.js & netlify
 
Intro to Vue
Intro to Vue Intro to Vue
Intro to Vue
 
Web Services with Objective-C
Web Services with Objective-CWeb Services with Objective-C
Web Services with Objective-C
 
OSGi and Spring Data for simple (Web) Application Development
OSGi and Spring Data  for simple (Web) Application DevelopmentOSGi and Spring Data  for simple (Web) Application Development
OSGi and Spring Data for simple (Web) Application Development
 

Destaque

Serverless Microservices - Real life story of a Web App that uses AngularJS, ...
Serverless Microservices - Real life story of a Web App that uses AngularJS, ...Serverless Microservices - Real life story of a Web App that uses AngularJS, ...
Serverless Microservices - Real life story of a Web App that uses AngularJS, ...Mitoc Group
 
Media tools to express understanding
Media tools to express understandingMedia tools to express understanding
Media tools to express understandingBrette Callaway
 
Node & Express as Workflow Tools
Node & Express as Workflow ToolsNode & Express as Workflow Tools
Node & Express as Workflow ToolsFITC
 
Scalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJSScalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJSAndhy Koesnandar
 
Wallpaper Final Piece
Wallpaper Final PieceWallpaper Final Piece
Wallpaper Final PieceFern Brereton
 
μετάταξη & πραγματικότητα
μετάταξη & πραγματικότηταμετάταξη & πραγματικότητα
μετάταξη & πραγματικότηταΣ.Ε.Π.Κ@
 
1335829820.8071 integrated%20hospital%20management%20system%20%5bihms%5d
1335829820.8071 integrated%20hospital%20management%20system%20%5bihms%5d1335829820.8071 integrated%20hospital%20management%20system%20%5bihms%5d
1335829820.8071 integrated%20hospital%20management%20system%20%5bihms%5dashlinrockey
 
Pawel Kuczinski
Pawel KuczinskiPawel Kuczinski
Pawel Kuczinskimaherran
 
Building a collaborative enterprise
Building a collaborative enterpriseBuilding a collaborative enterprise
Building a collaborative enterpriseSHAH JAHAN
 
집담회_6. 김문조
집담회_6. 김문조집담회_6. 김문조
집담회_6. 김문조gojipcap
 
PRIMER TRIMESTRE
PRIMER TRIMESTREPRIMER TRIMESTRE
PRIMER TRIMESTRETere Donet
 
Just Do it with jQuery
Just Do it with jQueryJust Do it with jQuery
Just Do it with jQueryselfteachme
 
Introduction to SPA with AngularJS
Introduction to SPA with AngularJSIntroduction to SPA with AngularJS
Introduction to SPA with AngularJSRiki Pribadi
 
Realtime web applications with ExpressJS and SocketIO
Realtime web applications with ExpressJS and SocketIORealtime web applications with ExpressJS and SocketIO
Realtime web applications with ExpressJS and SocketIOHüseyin BABAL
 
Lugares increíbles
Lugares increíblesLugares increíbles
Lugares increíblesmaherran
 
Chap001 (2) (1)
Chap001 (2) (1)Chap001 (2) (1)
Chap001 (2) (1)SHAH JAHAN
 
Testing Javascript Apps with Mocha and Chai
Testing Javascript Apps with Mocha and ChaiTesting Javascript Apps with Mocha and Chai
Testing Javascript Apps with Mocha and ChaiAndrew Winder
 
Doubleclick Training in Hyderabad | DoubleClick Training in Ameerpet | Doub...
Doubleclick  Training in  Hyderabad | DoubleClick Training in Ameerpet | Doub...Doubleclick  Training in  Hyderabad | DoubleClick Training in Ameerpet | Doub...
Doubleclick Training in Hyderabad | DoubleClick Training in Ameerpet | Doub...David Jacobs
 

Destaque (20)

Serverless Microservices - Real life story of a Web App that uses AngularJS, ...
Serverless Microservices - Real life story of a Web App that uses AngularJS, ...Serverless Microservices - Real life story of a Web App that uses AngularJS, ...
Serverless Microservices - Real life story of a Web App that uses AngularJS, ...
 
0 to Angular in 45 Mins
0 to Angular in 45 Mins0 to Angular in 45 Mins
0 to Angular in 45 Mins
 
Media tools to express understanding
Media tools to express understandingMedia tools to express understanding
Media tools to express understanding
 
Node & Express as Workflow Tools
Node & Express as Workflow ToolsNode & Express as Workflow Tools
Node & Express as Workflow Tools
 
Scalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJSScalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJS
 
Wallpaper Final Piece
Wallpaper Final PieceWallpaper Final Piece
Wallpaper Final Piece
 
Drafts Engl
Drafts EnglDrafts Engl
Drafts Engl
 
μετάταξη & πραγματικότητα
μετάταξη & πραγματικότηταμετάταξη & πραγματικότητα
μετάταξη & πραγματικότητα
 
1335829820.8071 integrated%20hospital%20management%20system%20%5bihms%5d
1335829820.8071 integrated%20hospital%20management%20system%20%5bihms%5d1335829820.8071 integrated%20hospital%20management%20system%20%5bihms%5d
1335829820.8071 integrated%20hospital%20management%20system%20%5bihms%5d
 
Pawel Kuczinski
Pawel KuczinskiPawel Kuczinski
Pawel Kuczinski
 
Building a collaborative enterprise
Building a collaborative enterpriseBuilding a collaborative enterprise
Building a collaborative enterprise
 
집담회_6. 김문조
집담회_6. 김문조집담회_6. 김문조
집담회_6. 김문조
 
PRIMER TRIMESTRE
PRIMER TRIMESTREPRIMER TRIMESTRE
PRIMER TRIMESTRE
 
Just Do it with jQuery
Just Do it with jQueryJust Do it with jQuery
Just Do it with jQuery
 
Introduction to SPA with AngularJS
Introduction to SPA with AngularJSIntroduction to SPA with AngularJS
Introduction to SPA with AngularJS
 
Realtime web applications with ExpressJS and SocketIO
Realtime web applications with ExpressJS and SocketIORealtime web applications with ExpressJS and SocketIO
Realtime web applications with ExpressJS and SocketIO
 
Lugares increíbles
Lugares increíblesLugares increíbles
Lugares increíbles
 
Chap001 (2) (1)
Chap001 (2) (1)Chap001 (2) (1)
Chap001 (2) (1)
 
Testing Javascript Apps with Mocha and Chai
Testing Javascript Apps with Mocha and ChaiTesting Javascript Apps with Mocha and Chai
Testing Javascript Apps with Mocha and Chai
 
Doubleclick Training in Hyderabad | DoubleClick Training in Ameerpet | Doub...
Doubleclick  Training in  Hyderabad | DoubleClick Training in Ameerpet | Doub...Doubleclick  Training in  Hyderabad | DoubleClick Training in Ameerpet | Doub...
Doubleclick Training in Hyderabad | DoubleClick Training in Ameerpet | Doub...
 

Semelhante a Web Development with AngularJS, NodeJS and ExpressJS

Normalizing x pages web development
Normalizing x pages web development Normalizing x pages web development
Normalizing x pages web development Shean McManus
 
Sofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworksSofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworksAndré Neubauer
 
The Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsThe Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsNicholas Jansma
 
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)Ran Mizrahi
 
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
 
LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) Sascha Sambale
 
Nitesh_Sr._Java_developer_Lead
Nitesh_Sr._Java_developer_Lead Nitesh_Sr._Java_developer_Lead
Nitesh_Sr._Java_developer_Lead Nitesh Dasari
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassSpike Brehm
 
Workshop HTML5+PhoneGap by Ivano Malavolta
Workshop HTML5+PhoneGap by Ivano Malavolta Workshop HTML5+PhoneGap by Ivano Malavolta
Workshop HTML5+PhoneGap by Ivano Malavolta Commit University
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Tom Brander
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | IntroductionJohnTaieb
 
Akshay_Paliwal_Lead_Developer
Akshay_Paliwal_Lead_DeveloperAkshay_Paliwal_Lead_Developer
Akshay_Paliwal_Lead_Developerakshaypaliwal23
 
Dog food conference creating modular webparts with require js in sharepoint
Dog food conference   creating modular webparts with require js in sharepointDog food conference   creating modular webparts with require js in sharepoint
Dog food conference creating modular webparts with require js in sharepointfahey252
 
Bruce lawson-over-the-air
Bruce lawson-over-the-airBruce lawson-over-the-air
Bruce lawson-over-the-airbrucelawson
 
Cloud development technology sharing (BlueMix premier)
Cloud development technology sharing (BlueMix premier)Cloud development technology sharing (BlueMix premier)
Cloud development technology sharing (BlueMix premier)湯米吳 Tommy Wu
 
Intro to jQuery @ Startup Institute
Intro to jQuery @ Startup InstituteIntro to jQuery @ Startup Institute
Intro to jQuery @ Startup InstituteRafael Gonzaque
 

Semelhante a Web Development with AngularJS, NodeJS and ExpressJS (20)

Normalizing x pages web development
Normalizing x pages web development Normalizing x pages web development
Normalizing x pages web development
 
Sofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworksSofea and SOUI - Web future without web frameworks
Sofea and SOUI - Web future without web frameworks
 
The Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsThe Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.js
 
Html5
Html5Html5
Html5
 
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)
 
Dust.js
Dust.jsDust.js
Dust.js
 
LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :)
 
Nitesh_Sr._Java_developer_Lead
Nitesh_Sr._Java_developer_Lead Nitesh_Sr._Java_developer_Lead
Nitesh_Sr._Java_developer_Lead
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master Class
 
Workshop HTML5+PhoneGap by Ivano Malavolta
Workshop HTML5+PhoneGap by Ivano Malavolta Workshop HTML5+PhoneGap by Ivano Malavolta
Workshop HTML5+PhoneGap by Ivano Malavolta
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | Introduction
 
Akshay_Paliwal_Lead_Developer
Akshay_Paliwal_Lead_DeveloperAkshay_Paliwal_Lead_Developer
Akshay_Paliwal_Lead_Developer
 
Dog food conference creating modular webparts with require js in sharepoint
Dog food conference   creating modular webparts with require js in sharepointDog food conference   creating modular webparts with require js in sharepoint
Dog food conference creating modular webparts with require js in sharepoint
 
Nodejs
NodejsNodejs
Nodejs
 
Bruce lawson-over-the-air
Bruce lawson-over-the-airBruce lawson-over-the-air
Bruce lawson-over-the-air
 
Cloud development technology sharing (BlueMix premier)
Cloud development technology sharing (BlueMix premier)Cloud development technology sharing (BlueMix premier)
Cloud development technology sharing (BlueMix premier)
 
Intro to jQuery @ Startup Institute
Intro to jQuery @ Startup InstituteIntro to jQuery @ Startup Institute
Intro to jQuery @ Startup Institute
 
Java script framework
Java script frameworkJava script framework
Java script framework
 

Último

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 

Último (20)

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 

Web Development with AngularJS, NodeJS and ExpressJS

  • 1. Laboratory of Databases and Web Applications Web development using Express, Node, Angular João Rocha da Silva (FEUP InfoLab, room I123) Contact: joaorosilva@gmail.com
  • 2. Contents 1. The MEAN Stack 2. NodeJS High-performance Javascript-based runtime environment 3. ExpressJS An MVC web applications framework 4. AngularJS Google framework for client apps in the browser 5. Live coding session + questions
  • 3. Javascript across the whole stack Image from https://codegeekk. wordpress.com/2015/03/07/explore- mean-stack-at-2015/
  • 5. NodeJS ● JavaScript “on the server side” ● Built on Google’s Chrome V8 Javascript engine ○ Compiles JavaScript code to native machine code instead of interpreting in real time ● Vibrant open-source community ○ Huge ecosystem of free libraries
  • 6. NodeJS (continued) ● Single thread, event-driven ○ Asynchronous, nonblocking I/O (i.e. not blocking the main thread) ○ Numerous & simultaneous I/O operations become faster ● Very low memory consumption vs PHP, for example ○ Single process ○ Many more simultaneous connections per server instance ○ Node sleeps when there is nothing to be done ● Multicore support also available for clusters In https://nodejs.org/en/about/ http://blog.soulserv.net/tag/node-js-vs-php/
  • 7. // 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/"); In https://nodejs.org/en/about/
  • 10. id username firstname surname 1 joao João Rocha Example: Listing all users Database table
  • 11. Route (JS) GET /users/all -> function(req,res) { //1. Fetch from DB User.findAll( … //2. Render view res.render( ‘users/all’, { users : users } ); } [ { "id" : 1, "username" : "joao", "firstname" : "João", "surname" : "Rocha" } ] <html> <h1>Viewing users</h1> <% for (var user in users… ) { %> Username : <%=user. username%> First Name: <%=users.firstname%> <% } %> </html> Model Route View Client requests http://127.0.0.1:3000/users/all Return Object array
  • 12. Database Querying API Model instancesModel Object-Relational Mapping (ORM) for NodeJS ● User “Class” “One for each DB table” ● Instances “One for each table row”
  • 13. Sequelize is a promise-based ORM for Node.js and io. js. It supports the dialects PostgreSQL, MySQL, MariaDB, SQLite and MSSQL and features solid transaction support, relations, read replication and more. Sequelize API Docs: http://docs.sequelizejs. com/en/latest/api/model/#findalloptions- promisearrayinstance
  • 14. Lots of libraries on the ecosystem Package manager for the web CSS, JS, HTML, Images... Bower Package manager for NodeJS Libraries Node Package Manager
  • 16. AngularJS ● HTML is good for presenting information ○ But NOT good for storing it ● jQuery uses the DOM to store information, and you need to set and get by element ID (usually) ○ Huge side effects as the code grows and different parts of the web page are modified at the same time by many events ○ Harder and harder to debug and maintain ● No one likes to maintain spaghetti code...
  • 17. ● Angular separates business logic and data from the presentation ○ Services and Factories for data access and storage ○ Views for presentation ○ Controllers are the “glue” between data and presentation ○ Routes switch between Views (Single Page Application) AngularJS (cont’d)
  • 19. AngularJS + ExpressJS are good friends ● Excellent for supporting Mobile Apps + Web site ○ Implement a single JSON-based API ○ Consume JSON on mobile devices ○ Same JSON can be used to generate HTML on the client ○ No need to test two separate APIs, because the site itself uses the “mobile” API
  • 21. Code for this presentation available at https://github.com/silvae86/lbaw_2016_tutorial João Rocha da Silva is just finishing an Informatics Engineering PhD at FEUP. He specializes on research data management, applying the latest Semantic Web Technologies to the adequate preservation and discovery of research data assets. He is experienced in many programming languages (Javascript-Node, PHP with MVC frameworks, Ruby on Rails, J2EE, etc etc) running on the major operating systems (everyday Mac user). Regardless of language, he is a quick learner that can adapt to any new technology quickly and effectively.