I am Hack Sparrow
Captain of the Internets.

My book on Express.js is published

I have been blogging about Express.js for quite some time now. Early this year, I was contacted by Packt (a leading technology publishing house), enquiring me if I'd be interested in writing a book on Express. A year ago, I had this idea to write a book on Express, which would be titled "Mastering Express.js", and worked out an early-stage table of contents for it. So when Packt contacted me, I told them that I would, in fact, be very inte ...

Express.js Custom Error Pages – 404 and 500

Express does a good job of handling 404 and 500 errors by default. However, many a times, the error is page is now what we would like it to look like. Is there a way to customize it? Yes there is. Online, you will come across many ways of implementing custom error pages for Express, but a lot of them do not use the correct approach, and those who do, do not explain properly how to do it, or what is going on. In this post I will show you how to create custom 404 and 500 error pages the right ...

How to serve static HTML files in Express.js

Express.js comes with a badass HTML pre-processor, Jade, but sometimes you may just want to use the good old HTML files for whatever reason. Is there a way to accomplish this? Oh yes, there is! The short and quick answer to this requirement is - dump the files in the [obj]public[/obj] directory! There is a slightly more elaborate but cleaner method, which will help you from cluttering up your [obj]public[/obj] directory with the HTML files - use the [obj]static[/obj] middleware. Create ...

JSLint from the Command Line

Maybe you have heard about JSLint, or maybe not. If you haven't yet, it is a popular JavaScript tool authored by Douglas Crockford, which helps you optimize your JavaScript code by telling you the problem areas and suggesting solutions for the same. Quite a nifty tool, try it here. Despite it's usefulness, the JSLint as we know it, has a little problem: it is an online tool, hosted on Crockford's server. Wouldn't it be wonderful if JSLint were a command ...

Loading JavaScript Modules in the Browser with Component.js

Is there a way to enable the module loading capability of Node.js in the browser? How wonderful it would be if you could write JavaScript modules the Node.js way and load them in the browser. There have been many attempts at doing this. Notable among them are RequireJS and Browserify. Both got things done one or the other way, but are unnecessarily complicated and a pain to use. If you type "browserify" or "requirejs" ...