Express Complete tutorial : Part 5

This is the last post on Express Complete tutorial series. Till now i have published how to configure, template, route and handle session.

In this final tutorial i am going to explain points to consider to finish up the Express app and get it ready for deployment.

Before deploying Express app, you should consider some important points. You must be very sure about the working of before hitting it to public. You should sure about these points:

  1. Is my app able to handle errors?
  2. Is my app able to survive the error and do not crash ?
  3. Is Session working correctly ?
  4. Is my app able to send emails?
  5. Is it doing some memory leaks ? (critical one)
  6. Is it able to resolve path of static files ?

Handling and Surviving Error:

Being a good developer you should always expect an error in your app. Error can happen any time under any situation.

Code which do not have error is not great code, the one survive it, is the one.

Fortunately, express have error handling mechanism. In every function call, you have one error callback variable. by using that you can code error prevention stuff.
For e.g

var express=require('express');
var app=express();

res.send('hello world');


This code is prone to error, what if user try to access ‘/home’. In that case express will throw 404 error but your code is not able to handle it. It should be like.

var express=require('express');
var app=express();

res.send('Some issue is here');
//take action accordingly
res.send('hello world');


This one is good practice.

Checking Sessions?

Like i have explained in last tutorial Sessions are very important. In every router code, you must validate whether the session is been set and if it is then what is the session variable and take action accordingly.

Sending emails in Express app?

E-mails are proven way to gain the user base and trust. Your app should also able to send e-mails in particular occasion to increase the level of personalisation with user.

I have explained about sending emails using Express in this tutorial.

Is there any memory leak?

Memory leak happens when program capture the amount of memory for execution and do not release them after finishing the execution.

It is very important to consider because unlike the development environment, production is more vulnerable to attacks !


To figure out this there is one popular and awesome package called memwatch. By using memwatch you can monitor and analyse the memory leaks. Of course you have to do it manually !

Reference reading : Mozilla hacks blog on memwatch

Resolving path in Express app?

Always using a relative path is good practice in development. However, if you don’t want that burden you can use path. For more information on using it, visit the official doc.

9 thoughts on “Express Complete tutorial : Part 5”

  1. Thanks a lot Shahid! I have been searching for an end to end simple tutorial for express.js. This was very simple yet striking on the key points…very helpful!!

  2. I must thank you for your tutorials, been learning node,js for the last week and I love it, now if you did one on using haversine to search in mySQL with node,js, that would be great. LOL.

  3. Good day, Shahid .
    English isn’t my native language.

    I’ve read this 5 articles about NodeJS.
    Thanks for your courses. They are very simple and capacious simultaneously.
    You have a talent to teach another people.

    Best regards.

  4. Terence Roberts

    Greetings! I dearly loved your work, excellent..nothing less than simply excellent!! You really gave me the insight that I have been looking for. You have a gift for teaching…..I hope that we will see more tutors from you.

  5. Good tutorials, would have been good if you provided complete code, can you do that?

  6. I got a basic node+express project up and running but it is running on . How do I get my domain name to actually point to the project on the web?

  7. Ravi Kumar Gupta

    Simple. Crisp. Tutorial. Perfect to get understanding of how this works. Thanks 🙂

Comments are closed.