APPENDIX A
Related Reading and Resources
This short appendix provides several of the most useful Node.js resources for further learning:
- Other Node.js frameworks
- Node.js books
- JavaScript classics
Other Node.js Frameworks
The Express.js framework is, no doubt, the most mature, popular, robust, tested, and used project for Node.js web services. As of this writing, Express.js is also the NPM repository with the highest number of stars from the NPM community, as shown in
. Express.js is the most starred NPM repository
Nevertheless, there are plenty of alternative Node.js frameworks to Express.js. To help developers navigate the numerous options, Ive created an analog to the TodoMVC collection ( ), so its great that you are getting to know Express.js!
. Node Frameworks provides a list of Node.js frameworks and their stats
Node.js Books
For more core Node.js overview and/or information about other components of the Node.js stack, such as databases and WebSockets, please consider these resources:
- Practical Node.js: Building Real-World Scalable Web Apps, by Azat Mardan (Apress, 2014): A Step-by-step guide to learning how to build scalable, real-world, web applications, taking you from installing Express.js to writing full-stack web applications.
- Rapid Prototyping with JS: Agile JavaScript Development (Azat Mardan, 2013): A Beginner-to-intermediate book on Node.js, MongoDB, and Backbone.js.
- JavaScript and Node FUNdamentals: A Collection of Essential Basics (Azat Mardan, 2014): A Short read on simple, but important concepts of browser JS and Node.
- Introduction to OAuth with Node.js: Twitter API OAuth 1.0, OAuth 2.0, OAuth Echo, Everyauth and OAuth2.0 Server Examples (Azat Mardan, 2014): A mini book about different OAuth scenarios.
- Pro Node.js for Developers, by Colin J. Ihrig (Apress, 2013): A Comprehensive, low-level book on Node.js sans any non-core modules.
- Node.js in Action, by Mike Cantelon et al. (Manning Publications, 2013): A Book by a variety of authors about Express.js and other topics.
- Learning Node, by Shelley Powers (O'Reilly Media, 2012): Covers Express, MongoDB, Mongoose, and Socket.IO.
- Node Cookbook, by David Mark Clements (Packt Publishing, 2012): Covers databases and WebSockets.
- Node: Up and Running, by Tom Hughes-Croucher and Mike Watson (O'Reilly Media, 2012): A brief overview of Node.js.
- Smashing Node.js: JavaScript Everywhere, by Guillermo Rauch (Wiley, 2012): Covers Express.js, Jade, and Stylus, from the creator of Mongoose ORM for MongoDB.
JavaScript Classics
For a deeper understanding of JavaScript, the most misunderstood and most popular programming language, be sure to read these proven classics:
- Eloquent JavaScript, Second Edition, by Marijn Haverbeke (No Starch Press, 2014): Programming fundamentals in JavaScript coding.
- JavaScript: The Good Parts, by Douglas Crockford (OReilly Media, 2008): Deals with the tricky parts of the JavaScript language.
Courses
If you liked this book, then check out Azats Node.js courses: Node Program ( http://nodeprogram.com ) and Mongoose Course ( http://mongoosecourse.com ).
__________________
APPENDIX B
Migrating Express.js 3.x to 4.x: Middleware, Route, and Other Changes
Express.js 4 ( http://expressjs.com ) is the latest (as of May 2014), major version of the most popular, mature, and robust Node.js framework for web apps, services, and APIs. There are some breaking changes in the transition from 3.x to 4.x, so this appendix serves as a brief migration guide, with coverage of the following:
- Introducing unbundled middleware in Express.js 4
- Removing deprecated methods from Express.js 4 apps
- Other Express.js 4 changes
- Exploring the new Express.js 4 route instance and how to chain it
- Further Express.js 4 migration reading links
Even if you have no intention of working with version 3, this guide might be useful to you, because it sheds light on the rationale for making the changes from Express 3 to 4, and the philosophy behind those changes.
Introducing Unbundled Middleware in Express.js 4
Lets start with the biggest change that will break most of your Express.js 3.x projects. This is also the most discussed (and long awaited?) Express.js news on the Internet. Yes, its unbundled middleware.
Personally, Im not sure whether its good news or bad news, because I kind of liked not having to declare extra dependencies. However, I can see the arguments in favor of unbundling as well, including benefits, such as keeping the Express.js module small, upgrading middleware packages independently, and so forth.
So, what is unbundled middleware? Remember the magic middleware that we were able to use, simply by typing app.use(express.middlwarename()) ? Well, they were coming from the Connect library, but now they are no longer part of Express.js. It was customary to write, for example, app.use(express.cookieParser()) in Express.js 3.x. Those modules are essential for pretty much any web application. They were part of the Connect library, but Express.js 4.x doesnt have Connect as a dependency. This means that, if we want to use middleware (and we sure do!), well need to include middleware explicitly, like this:
$ npm install body-parse@1.0.2 --save
Then, in the Express.js main configuration file (e.g., app.js ), we use the included module like this:
var bodyParser = require('body-parse')
// ... other dependencies
app.use(bodyParser())
// ... some other Express.js app configuration
describes the unbundled middleware that developers will have to replace: all except static. Thats right, static was left out (for convenience?). The table lists the Express.js 3.x middleware names and their NPM module counterparts for Express.js 4.x usage.
. Middleware comparison
Express.js 3.x | Express.js 4.x | GitHub Link |
---|
express.bodyParser | body-parser | https://github.com/expressjs/body-parser |
express.compress | compression | https://github.com/expressjs/compression |
express.timeout | connect-timeout | https://github.com/expressjs/timeout |
express.cookieParser | cookie-parser | https://github.com/expressjs/cookie-parser |
express.cookieSession | cookie-session | https://github.com/expressjs/cookie-session |
express.csrf | csurf | https://github.com/expressjs/csurf |
express.error-handler | errorhandler | https://github.com/expressjs/errorhandler |
express.session | express-session | https://github.com/expressjs/session |
express.method-override | method-override | https://github.com/expressjs/method-override |
express.logger |
Next page