- remove_red_eye7136 Views
- event30 Oct 2014
- access_time4 min read
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:
- Is my app able to handle errors?
- Is my app able to survive the error and do not crash ?
- Is Session working correctly ?
- Is my app able to send emails?
- Is it doing some memory leaks ? (critical one)
- 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.
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.
res.send('Some issue is here');
//take action accordingly
This one is good practice.
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