A presentation given by me during an invited lecture at FEUP. Topics covered:
The MEAN Stack (MongoDB, ExpressJS, AngularJS and NodeJS
NodeJS (High-performance Javascript-based runtime environment)
ExpressJS (An MVC web applications framework)
AngularJS (Google framework for client apps in the browser)
Live coding session + questions
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/
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.