When I started working at Storify as a Node.js Engineer. The tech stack was Express and Jade. I hate to admit it, but I struggled with Jade a lot!
Before, I mostly worked with Underscore, and Handlebars. I attempted to modify some HTML in the Jade templates. Other times I would only change the text. Those were trivial updates, but very often they cause the whole server to crash.
I was failing miserably to learn by trial and error. I hated Jade. I was starting to hate editing templates as well. Then I had a light bulb moment: I need a tutorial. I went to the official docs. I wish this article existed at that time. After spending just an hour learning Jade, I was able to use Jade and make all the changes to templates smoothly.
Smart people learn by their mistakes, and wise people learn from others. Don’t repeat my folly. Skim through this Jade tutorial to harness the power of this wonderful template language.
Test-driven development (TDD) , as many of you might know, is one of the main, agile development techniques. The genius of TDD lies in increased quality of code, faster development resulting from greater programmer confidence, and improved bug detection (duh!).
Historically, web apps have been hard to autotest, and developers relied heavily on manual testing. But, certain parts such as standalone services and REST API can be and should be tested thoroughly by the TDD. At the same time, rich user interface (UI) / user experience (UX) can be tested with headless browsers such as PhantomJS.
UPDATE May 21, 2016: The io.js became Node.js and everything is better then ever. Conclusion? Avoid drama, speculations and distractions. Just keep on building useful and good applications.
There have been a lot of buzz around io.js for the past few months. Basically, io.js is a branched (forked in Git/GitHub terminology) version of Node.js.
One of the main reasons to deviate from the main Node.js project was to speed up the development. This way io.js can have more recent features from Google Chrome V8 and ECMAScript6. Those are good things, right? Then, why there has been so many concerns over the future of Node.js/io.js? Why some people were confused and skeptical?
Last week, I did a live Q&A session for people who bought my new book Pro Express.js, but you can watch the recording here. Click on the apps icon (next to the ? icon), and then click on the Q&A button to see the questions. If you haven’t bought Pro Express.js, then you can do it on Amazon.com… and start mastering the framework for you Node.js web development.
The long-anticipated Express.js manual is ready and was sent to to print at this week (December 24, 2014). To summarize the book, Pro Express.js: Master Express.js—The Node.js Framework For Your Web Development is all about understanding Express.js and building web apps with this framework and its middleware. Spend two minutes to read this post, to know how you can benefit from this valuable resource and the release.
Becoming a Better Node.js Developer
If you an intermediate or advanced beginner Node.js developer and want to become better at this cool, new technology, then you have lots of questions about the best practices and patterns. Most likely you’ve encountered Express.js, and you wish you knew more about useful settings and options to configure Express.js and its middleware.
The reason why I know these things is that, before I became proficient with Node.js and Express.js, I was a beginner just like you. Also, I’ve been in a position when I needed to learn Express.js quickly. In those sad moments, I was flat out miserable and often had to read the source code for the lack of a good documentation and examples. I wish I had Pro Express.js with me back then to explain the mechanisms in plain English, and provide inspiring code patterns that I could re-use in my projects. That’s why I’m confident that Pro Express.js will be great for intermediate Node.js developers (and advanced-beginners).
Pro Express.js can solve your pains and problems by providing the following benefits:
To review, the typical structure of an Express.js app fig(which is usually a server.js or app.js file) roughly consists of these parts, in the order shown:
Dependencies : A set of statements to import dependencies
Instantiations : A set of statements to create objects
Configurations : A set of statements to configure system and custom settings
Middleware : A set of statements that is executed for every incoming request
Routes : A set of statements that defines server routes, endpoints, and pages
Bootup : A set of statements that starts the server and makes it listen on a specific port for incoming requests
This chapter covers the fifth category, routes and the URL parameters that we define in routes. These parameters, along with the app.param() middleware, are essential because they allow the application to access information passed from the client in the URLs (e.g., books/proexpressjs). This is the most common convention for REST APIs. For example, the http://hackhall.com/api/posts/521eb002d00c970200000003 route will use the value of 521eb002d00c970200000003 as the post ID.
Parameters are values passed in a query string of a URL of the request. If we didn’t have Express.js or a similar library, and had to use just the core Node.js modules, we’d have to extract parameters from an HTTP.request object via some require('querystring').parse(url) or require('url').parse(url, true) function “trickery.”
Let’s look closer at how to define a certain rule or logic for a particular URL parameter.
TL;DR: This text is an excerpt (Chapter 9) from Pro Express.js: Master Express.js—The Node.js Framework For Your Web Development. The book will be released next week (December 24, 2014), and we’ll announce a great limited-time offer on it on Sunday, December 28, 2014. So stay tuned… and happy Holidays!!!
Good web applications must have informative error messages to notify clients exactly why their request has failed. Errors might be caused either by the client (e.g., wrong input data) or by the server (e.g., a bug in the code).
The client might be a browser, in which case the application should display an HTML page. For example, a 404 page should display when the requested resource is not found. Or the client might be another application consuming our resources via the REST API. In this case, the application should send the appropriate HTTP status code and the message in the JSON format (or XML or another format that is supported). For these reasons, it’s always the best practice to customize error-handling code when developing a serious application.
In a typical Express.js application, error handlers follow the routes. Error handling deserves its own section of the book because it’s different from other middleware. After the error handlers, we’ll cover the Express.js application methods and ways to start the Express.js app. Therefore, the major topics of this chapter are as follows:
This text is part of my new book Pro Express.js: Master Express.js—The Node.js Framework For Your Web Development [Apress, 2014]. Security is important, that’s why I decided to publish this chapter on my blog. The book will be released very soon.
The set of tips in this chapter deals with security in Express.js applications. Security is often a neglected topic that is deferred until the last minute before the release. Obviously, this approach of treating security as an afterthought is prone to leaving holes for attackers. A better approach is to consider and implement security matters from the ground up. Continue reading “Express.js Security Tips”
If you don’t know what the Node Frameworks project is about—check it out. The mission of this resource is to provide recommendations and one place for discovering Node.js frameworks and tutorials/examples for them. The stats for each library is really interesting to compare.
LoopBack is a comprehensive Node.js web framework with a rich command-line scaffolding and a web API explorer: strongloop.com/node-js/loopback. The framework is maintained by StrongLoop which is also the gate-keeper of Express.js.
This concise tutorial will illustrate how to get started with LoopBack and the common traits between LoopBack and Express.js. This text is from my new book Pro Express.js by Apress which you can already start reading in Apress Alpha or pre-order on Amazon.com and other bookstores.
Sails.js (GitHub) is a convention-over-configuration type of a framework. This means that it’s similar in philosophy to Ruby on Rails. Sails.js is a true MVC framework, unlike Express.js which relies on developers for adding ORMs like Mongoose. Sails.js uses the Waterline ORM.
Now our hand-picked registry of Node.js frameworks (NodeFrameworks.com) has GitHub statistics right on the website, so you don’t have to navigate back and forth when making a decision!
This is how it looks: each framework has a number (GitHub stars) next to its name. This serves as a social proof meaning the more people use the framework the more robust it is and the less bugs it has.
The buttons provided by the service called GitHub Buttons. The links to the frameworks’ GitHub, NPM, examples and other resources are hidden under the “i” icon.
Express.js is one of the top Node.js frameworks out there. It was used in the overwhelming majority of projects that I’ve encountered since I began working with Node.js in 2011. One of the main selling points and key differentiators is the framework’s configurability. However, while writing Express.js Guide and Pro Express.js, I discovered a few secret settings never mentioned in their documentation.
Are you a software engineer who wants to master an effective and fun-to-use, new platform Node.js? Is your goal to stay on top of the curve with cutting-edge technology, and to stay ahead of the competitive software engineering industry by delivering high quality products faster?
MongoUI is a real-time web interface for Node.js and MongoDB written with DerbyJS—a real-time full-stack web framework. It’s a app that can be run locally and on the server. Similarly, you can view and manipulate data in a local or remote database. The MongoUI project is in beta so use caution, and please contribute your feedback.