This session will show you a few http frameworks, mainly from express to koa. How they work, a few examples with source code, my personal experiences with pros and cons to maybe make your decision a bit easier.
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
// Database request db.collection.find( “user“, { user: req.session.userid }, function( err, data ) { // no user found if (err || !data) { console.log( “Not a valid user!“ ); return res.status( 500 ).send( “Not a valid user!“ ); } // valid user -> go down the chain console.log( “Valid user!“ ); next(); }); } Node.js – from the Beginning express 22-Apr-16
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
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
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
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
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
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
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