Slide 1

Slide 1 text

Page 1 Node.js from the beginning LINKWORK, März 2016, Landshut 22-Apr-16 Node.js – from the Beginning

Slide 2

Slide 2 text

Page 2 §  Robert Prediger §  20 years: Progress §  15 years: Web development §  5 years: Node.js §  [email protected] 22-Apr-16 Introduction Node.js – from the Beginning

Slide 3

Slide 3 text

Page 3 Installation 22-Apr-16 Node.js – from the Beginning

Slide 4

Slide 4 text

Page 4 Installation 22-Apr-16 Node.js – from the Beginning

Slide 5

Slide 5 text

Page 5 npm is a piece of technology, but more importantly, it is a community. npm makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update the code that you're sharing. https://www.npmjs.com/ Node.js – from the Beginning npm 22-Apr-16

Slide 6

Slide 6 text

Page 6 npm Node.js - What? 6-Nov-15

Slide 7

Slide 7 text

Page 7 npm Node.js – from the Beginning 22-Apr-16 Source: http://www.modulecounts.com/

Slide 8

Slide 8 text

Page 8 Socket.IO enables real-time bidirectional event-based communication. It works on every platform, browser or device, focusing equally on reliability and speed. USED BY EVERYONE From Microsoft Office, Yammer, Zendesk, Trello... to hackathon winners and little startups. http://socket.io/ Node.js – from the Beginning socket.io 22-Apr-16

Slide 9

Slide 9 text

Page 9 var express = require('express'), app = express(), server = require('http').createServer( app ).listen( config.port ), io = require('socket.io').listen( server ), numConn = 0; ... Node.js – from the Beginning socket.io 22-Apr-16

Slide 10

Slide 10 text

Page 10 ... io.on( 'connection', function(socket) { numConn += 1; console.log( "connected", numConn ); // event for login from socket socket.on( "login", function ( name ) { socket.nickname = name; }); ... socket.on( "disconnect", function() { numConn -= 1; console.log( "disconnect", numConn ); }); }); Node.js – from the Beginning socket.io 22-Apr-16

Slide 11

Slide 11 text

Page 11 ... // socket sends message socket.on( "sendMessage", function( msg ) { console.log( "send message", numConn, socket.nickname, msg ); // broadcast message to all subscribed sockets socket.broadcast.emit( "newMessage", { name: socket.nickname, msg: msg } ); }); ... Node.js – from the Beginning socket.io 22-Apr-16

Slide 12

Slide 12 text

Page 12 Fast, unopinionated, minimalist web framework for Node.js Minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. http://expressjs.com/ Node.js – from the Beginning express 22-Apr-16

Slide 13

Slide 13 text

Page 13 express 22-Apr-16 Node.js – from the Beginning favicon Static-Files Log Process Request ... (other middleware modules)

Slide 14

Slide 14 text

Page 14 var express = require('express'), app = express(); app.get( "/rest/:table", auth, function( req, res ) { res.send( "Request: " + req.params.table ); }); app.get( "/rest/:table/:id", auth, function( req, res ) { res.send( req.params ); }); app.get( "/", function( req, res ) { console.log( "req" ); res.send( "Hello World" ); }); app.listen( 80 ); Node.js – from the Beginning express 22-Apr-16

Slide 15

Slide 15 text

Page 15 var express = require('express'), app = express() , router = express.Router(); // use router with prefix app.use( "/rest", auth, router ); router.get( "/:table", function( req, res ) { res.send( "Request: " + req.params.table ); }); router.get( "/:table/:id", function( req, res ) { res.send( req.params ); }); app.get( "/", function( req, res ) { console.log( "req" ); res.send( "Hello World" ); }); app.listen( 80 ); Node.js – from the Beginning express 22-Apr-16

Slide 16

Slide 16 text

Page 16 var express = require('express'), app = express(); app.use( function( req, res, next ) { var start = new Date; console.log( "way down", req.url ); next(); console.log( 'way back' ); console.log( 'Response-Time', new Date - start ); }); app.get( "/", function( req, res ) { console.log( "req" ); res.send( "Hello World" ); }); app.listen( 80 ); Node.js – from the Beginning express 22-Apr-16

Slide 17

Slide 17 text

Page 17 var express = require('express'), app = express(); app.use( function( req, res, next ) { var start = new Date; console.log( "way down", req.url ); next(); console.log( 'way back' ); console.log( 'Response-Time', new Date - start ); }); app.get( "/", function( req, res ) { process.nextTick( function() { console.log( "req" ); res.send( "Hello World" ); }); }); app.listen( 80 ); Node.js – from the Beginning express 22-Apr-16

Slide 18

Slide 18 text

Page 18 Enterprise Node to Power the API Economy No matter where you are in the lifecycle of developing APIs with Node, StrongLoop has a complete set of command-line and graphical tools that can work together or independently to help you succeed. https://strongloop.com/ Node.js – from the Beginning StrongLoop 22-Apr-16

Slide 19

Slide 19 text

Page 19 Strongloop Node.js – from the Beginning 22-Apr-16

Slide 20

Slide 20 text

Page 20 Strongloop Node.js – from the Beginning 22-Apr-16 Source: https://strongloop.com/node-js/arc/

Slide 21

Slide 21 text

Page 21 Strongloop Node.js – from the Beginning 22-Apr-16 Source: https://strongloop.com/node-js/arc/

Slide 22

Slide 22 text

Page 22 The web framework of your dreams Built for developers by a giant squid. Sails makes it easy to build custom, enterprise-grade Node.js apps. It is designed to emulate the familiar MVC pattern of frameworks like Ruby on Rails, but with support for the requirements of modern apps. http://sailsjs.org/ Node.js – from the Beginning SailsJS 22-Apr-16

Slide 23

Slide 23 text

Page 23 SailsJS Node.js – from the Beginning 22-Apr-16 Source: https://www.manning.com/books/sails-js-in-action

Slide 24

Slide 24 text

Page 24 SailsJS Node.js – from the Beginning 22-Apr-16 Source: https://www.manning.com/books/sails-js-in-action

Slide 25

Slide 25 text

Page 25 next generation web framework for node.js Koa is a new web framework designed by the team behind Express, which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs. http://koajs.com/ Node.js – from the Beginning Koa 22-Apr-16

Slide 26

Slide 26 text

Page 26 var koa = require('koa'), app = koa(); app.use( function *(next){ var start = new Date; yield next; var ms = new Date - start; this.set('Response-Time', ms + 'ms'); }); app.use( function *(){ this.body = 'Hello World'; }); app.listen( 80 ); Node.js – from the Beginning Koa (1.x) 22-Apr-16

Slide 27

Slide 27 text

Page 27 var Koa = require('koa'), app = new Koa(), co = require('co'); app.use( co.wrap( function *( ctx, next){ const start = new Date; yield next(); var ms = new Date - start; console.log( 'Response-Time', ms ); })); app.use( ctx => { ctx.body = 'Hello World'; }); app.listen( 80 ); Node.js – from the Beginning Koa (2.x) 22-Apr-16

Slide 28

Slide 28 text

Page 28 The Web framework beyond your dreams ThinkJS is the first Node.js MVC framework that supporting use full ES6/7 features to develop Node.js application. https://thinkjs.org/ Node.js – from the Beginning ThinkJS 22-Apr-16

Slide 29

Slide 29 text

Page 29 ThinkJS Node.js – from the Beginning 22-Apr-16

Slide 30

Slide 30 text

Page 30 ThinkJS Node.js – from the Beginning 22-Apr-16

Slide 31

Slide 31 text

Page 31 ThinkJS Node.js – from the Beginning 22-Apr-16

Slide 32

Slide 32 text

Page 32 Disadvantages Even though ThinkJS has many advantages, it has also a few disadvantages too, for example: •  ThinkJS is a relatively new framework, the community is not strong enough. •  ThinkJS is short of large scale applications. Node.js – from the Beginning ThinkJS 22-Apr-16

Slide 33

Slide 33 text

Page 33 Build powerful back-end with no effort. Fast. Reusable. Easy to use. The next generation framework for Node.js built on top of Koa. http://strapi.io/ Node.js – from the Beginning strapi 22-Apr-16

Slide 34

Slide 34 text

Page 34 strapi Node.js – from the Beginning 22-Apr-16

Slide 35

Slide 35 text

Page 35 strapi Node.js – from the Beginning 22-Apr-16

Slide 36

Slide 36 text

Page 36 strapi Node.js – from the Beginning 22-Apr-16

Slide 37

Slide 37 text

Page 37 22-Apr-16 Node.js – from the Beginning That‘s it J Thank you very much for listening [email protected] Sourcecode:https://github.com/web4biz/Node.js-FromTheBeginning