European Windows 2019 Hosting BLOG

BLOG about Windows 2019 Hosting and SQL 2019 Hosting - Dedicated to European Windows Hosting Customer

Node.js Hosting - HostForLIFE.eu :: Node.js Proxy Configurations on Windows

clock December 13, 2016 10:12 by author Peter

In this article, let me show you how to setup Node.js proxy configurations on Windows. It is often required to work with Node.JS and NPM package installer behind the proxy. When trying to install npm packages behind the proxy, you may come across the error, given below:

To resolve exceptions, shown above, http_proxy and https_proxy configurations needs to be done for NPM. The step by step guidance is given below to perform the configuration on Windows machine.

  • Go to C:\User\{User} directory.
  • If .npmrc file exists then open it in notepad editor else create .npmrcfile.
  • Add the lines, given below to the file for your valid AD domain user. proxy=http://domain\\username:password@ip:port
  • Add the lines, given below for Non AD user proxy=http://username:password@ip:port
  • Save .npmrc file
  • Try to use npm install now. It should work without any error.

The sample contents of .npmrc file are shown below:



Node.js Hosting Germany - HostForLIFE.eu :: How to Create Server Using Express.js in Node.js ?

clock March 10, 2015 06:32 by author Peter

This time we will follow a complete and a smart way to create a HTTP server that is exact and quick in Node.js.

Express is insignificant and adaptable Node.JS web application framework that gives a vigorous set of gimmicks of web and portable application. What's more, it will help you in making APIs that verifiably take a shot at the HTTP protocol.

Installation
Express.JS is a framework file hosted by the Node Package Manager (NPM). For installation, we have a special node command to install on the local computer. Write the following code:
npm install [PACKAGE NAME]

And this is code for installing express:
node install express

Note: express is the package name.

After Installing, you will get a folder node_modules that consists of all the modules that you install from npm.

Finally, you have successfully installed the express module in your node folder. Now, write the following code:
// Express
var fs=require("fs");
var host="127.0.0.1";
var port="1337";

//Express
var express=require("express");
var app=express();
app.ger("/",fuction(request, response){
  response.send("Express is Working !!");
});

//Listening Socket
app.listen(port,host);


We utilize the term standard code with express on the grounds that it evacuates the undesirable lines. The code that minimizes the lines of code to do a certain task.  Also, express permits us to make a HTTP server in a couaple of lines of code. And here is the output:

I hope it works for you!

HostForLIFE.eu Node.js Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.

 



Node.js Hosting Netherlands - HostForLIFE.eu :: Stream a Large File using Node.js

clock February 12, 2015 05:46 by author Peter

Node.js is an open source, cross-platform runtime environment for server-side and networking applications. Node.js applications are written in JavaScript, and might be run within the Node.js runtime on OS X, Microsoft Windows, Linux and FreeBSD. Node.js provides an event-driven architecture and a non-blocking I/O API that optimizes an application's outturn and measurability. These technologies are normally used for real-time applications.

Node.js uses the Google V8 JavaScript engine to execute code, and an oversized percentage of the fundamental modules are written in JavaScript. Node.js contains a intrinsic  library to permit applications to act as an internet server while not software like Apache HTTP Server or IIS.
var http = require('http');
var fs = require('fs');
http.createServer(function(req, res) {
    var newFile = fs.createWriteStream("x.wmv");
    var fileBytes = req.headers['content-length'];
    var uploadedBytes = 0;
    req.pipe(newFile);
    req.on('data', function(chunk) {
        uploadedBytes += chunk.length;
        var progress = (uploadedBytes / fileBytes) * 100;
        res.write("progress:" + parseInt(progress, 10) + "\n");
    });
    res.write("Done");
}).listen(8888);

HostForLIFE.eu Node.js Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



Node.js Hosting UK - HostForLIFE.eu :: Creating HTTPS Server With Node.js

clock January 15, 2015 07:04 by author Peter

HTTP server was ok for us to try and do numerous operations that we've performed within the articles lately. During this specific article however, we are going to be looking at a way to create HTTPS server instead with Node.js.

We use HTTPS after we would like secure sessions. A secure session implies that the online browser can encrypt everything you are doing with a digitally signed certificate. Therefore clearly before you are doing HTTPS, you would like to make certificates. Let's therefore spend a while to check a way to develop certificates for SSL.

Make a SSL Certificates
In order to make a certificate, you need to download a small tool OpenSSL first from this link https://code.google.com/p/openssl-for-windows/downloads/list

Download the version as per your system's specification, it's essentially a zip file. Once downloaded, extract the content to a such location onto your disc drive. Now open the location of the extracted content and copy the file openssl.cnf to the bin folder.

That is the configuration file for the Openssl. Next, open CMD, change the directory to this folder and execute the following code.

openssl req -config openssl.cnf -x509 -days 365 -newkey rsa:1024 -keyout hostkey.pem -nodes -out hostcert.pem

The program can then a few you for a few peices of data for creating the certificate. in the end of everything, you may have 2 files hostcert.pem and hostkey.pem, that is our certificate and key file respectively, that we are going to be using in our HTTPS server.

Creating HTTPS server
Just like we have a tendency to do for HTTP, an import to node's HTTP module, for HTTPS we import the HTTPS module. Also, since we'd like to pass within the certificate and key file, we also need to import the filestream (fs) module to enable Node to read the files. the following is that the code to make the HTTPS server.
var https = require('https'); 
var fs = require('fs'); 
   var options = { 
  key: fs.readFileSync('hostkey.pem'), 
  cert: fs.readFileSync('hostcert.pem') 
}; 
https.createServer(options, function (req, res) { 
 res.writeHead(200); 
  res.end("hello world\n"); 
}).listen(8000); 


Of course you wish to copy the files into the same location because the node program. now if you explore the code above, you will find that it's very similar to what we discussed before, like reading files, making a http server so on. The change however is that the https.createServer() method that takes another parameter, that is that the certificate and key for the SSL.

Now if you run the code and see it in a browser, this can be how it looks:
Select proceed anyway option as of now, as our browser does not understand our amazing certificate.



About HostForLIFE

HostForLIFE is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2019 Hosting, ASP.NET 5 Hosting, ASP.NET MVC 6 Hosting and SQL 2019 Hosting.


Month List

Tag cloud

Sign in