How to Update Node.js and npm on Windows

May 23, 2018 superadmin 0

As of now, Node.js is a fast-moving project and Minor updates come out every few weeks to boost stability and security among all version branches.The process of installing Node.js on Windows is almost the same as the process to upgrade Node.js on Windows. Install Node.js 1. First we need to download node installer from the official website: http://nodejs.org. Download the latest recommended LTE version. 2. After the download has completed, double-click the .msi package. As of this writing, the MSI is node-v8.11.2-x64.msi. 3. Click Run. 4. Click Next. 5. Check I accept the terms in the License Agreement. Click Next. [...]

Node.js Security

October 10, 2017 superadmin 0

Everyone knows how security is very important to our application. So i have put together this checklist to help you guide through the must have security checks before your application is enabled to thousands of users. Use TLS ( Transport Layer Security) If you transmits sensitive data, use Transport Layer Security (TLS) to secure the connection and the data. TLS encrypts data before it is sent from the client to the server, thus preventing some common (and easy) hacks. Disable X-Powered-By header: If you don’t want to use Helmet, then at least disable the X-Powered-By header. Attackers can use this [...]

HTTP Methods for RESTful Services with Examples (Mongoose)

October 9, 2017 superadmin 0

The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT, PATCH, and DELETE. These correspond to create, read, update, and delete (or CRUD) operations, respectively. POST – Create This is how we can create new items in the database. This will commonly be from an HTTP POST request, although you can do this anywhere you want var article = new Article(req.body); article.save((err, article) => { if (err) { res.status(500).send(err); } res.status(200).send(article); }); GET – Read Here the example like, how HTTP get method are typically used in a RESTful API: 1. Finds all [...]

Error-first callback in node.js

September 19, 2017 superadmin 0

The “error-first” callback is nothing but a standard protocol for Node callbacks. Error-first callbacks are used to pass errors and data as well. The “error-first” callback has a simple rule that the first argument for the callback function should be an error object and it has to be checked to see if something went wrong. Additional arguments are used to pass data. fs.readFile(“./test.php”, function(err, data) { if (err) { // handle the error, the return is important here // so execution stops here return console.log(err) } // use the data object console.log(data) }) As you can see in the above [...]

What is Callback hell in Node.JS

September 19, 2017 superadmin 0

Callback hell “refers to heavily nested callbacks that have become unreadable. To fix this we can break callbacks into independent functions that is referred as modularization. An Example of heavily nested code is below: query(“SELECT userId FROM userss WHERE userName=’jhon’;”, function(id){ query(“SELECT * FROM articles WHERE articleId=” + id, function(articles){ articles.each(function(article){ query(“UPDATE articles SET status = ’0′ WHERE id=” + article.id, function(error){ if(!error){ console.log(“success!!”); }else{ console.log(“error”); } }); }); }); }); To fix this, the above callbacks are broken out into independent functions which can be called with some parameters. var logError = function(error){ if(!error){ console.log(“success!!”); }else{ console.log(“error”); } }, [...]