diff --git a/.htaccess b/.htaccess index 8010332..e2dfcf2 100644 --- a/.htaccess +++ b/.htaccess @@ -1 +1 @@ -AddType x-mapp-php5 .php .shtml .html .htm +AddType x-mapp-php5 .php .shtml .html .htm .js .css .png .jpg .gif diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..fa867eb --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,5 @@ +Copyright 2011-2018 Manuel Kiessling + +The contents in this repository are free for personal use. + +It is not permitted to copy (with the exception of Github forks), distribute, display, and perform the work, as well as make and distribute derivative works based on it, unless specifically granted. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0345500 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +This is the source code of https://www.nodebeginner.org. diff --git a/_defaultheaders.php b/_defaultheaders.php index bc12429..1694439 100644 --- a/_defaultheaders.php +++ b/_defaultheaders.php @@ -1,3 +1,4 @@ + diff --git a/_googleanalytics.php b/_googleanalytics.php index 31412fb..e69de29 100644 --- a/_googleanalytics.php +++ b/_googleanalytics.php @@ -1,11 +0,0 @@ - - diff --git a/_hreflang.php b/_hreflang.php index 95d6140..23fe6e4 100644 --- a/_hreflang.php +++ b/_hreflang.php @@ -4,7 +4,7 @@ - - + + diff --git a/_phpinfo.html b/_phpinfo.html new file mode 100644 index 0000000..951cbbd --- /dev/null +++ b/_phpinfo.html @@ -0,0 +1,3 @@ + - + - The Node Beginner Blog · The Node Beginner Blog +The Node Beginner Blog - The Node Beginner Blog + + + + + + + + + + + + + + + + + + + + - + @@ -24,13 +44,69 @@

The Node Beginner Blog

-

Node.js tutorials, how-to's, and more.

+

Your regularly updated tutorial resource for all things Node.js.

+
+

Setting up a JavaScript project for ES6 development with Babel and Webpack

+ + + +
+

JavaScript is a language and an ecosystem which constantly evolves. This changes the way we can write JavaScript and +Node.js code, and it often demands special tooling to be able to do so. This tutorial shows how to set up a project +with Babel and Webpack, which allows you to write modern ES6 JavaScript code for the browser and the server.

+ Read more +
+ +
+ +
+

JavaScript News and Resources - October 2017

+ + + +
+

The first issue of our monthly JavaScript ecosystem and community overview gets you covered with the most important reports, tutorials, and resources of the month.

+ Read more +
+ +
+ +
+

Node.js tutorial: Super-fast web applications with the WebSocket protocol

+ + + +
+

The WebSocket protocol is an extension to the HTTP ecosystem which allows to create live connections between a +web server and a web browser, enabling web applications to efficiently exchange data in real-time without the overhead +of conventional HTTP connections. Node.js is perfectly suited for writing WebSocket applications, and this tutorial +explains how it all works.

+ Read more +
+ +
+ +
+

Explained: What are Node.js modules?

+ + + +
+

When you write Node.js applications, you could actually put all your code into one huge index.js file, no matter +how large or complex your application is. The Node.js interpreter doesn’t care. But in terms of code organization, +you would end up with a hard to understand and hard to debug mess quite quickly. So as a human being, you should care +about how to structure your code. This is where modules come in.

+ Read more +
+ +
+

Node.js tutorial: Optimizing code performance using async

@@ -83,17 +159,6 @@

- - diff --git a/blog/index.xml b/blog/index.xml index abb5433..1dc6926 100644 --- a/blog/index.xml +++ b/blog/index.xml @@ -6,11 +6,55 @@ Recent content on The Node Beginner Blog Hugo -- gohugo.io en-us - Tue, 06 Jun 2017 08:22:42 +0200 + Sun, 08 Oct 2017 09:18:00 +0200 + + Setting up a JavaScript project for ES6 development with Babel and Webpack + https://www.nodebeginner.org/blog/post/setting-up-a-javascript-project-for-es6-development-with-babel-and-webpack/ + Sun, 08 Oct 2017 09:18:00 +0200 + + https://www.nodebeginner.org/blog/post/setting-up-a-javascript-project-for-es6-development-with-babel-and-webpack/ + <p>JavaScript is a language and an ecosystem which constantly evolves. This changes the way we can write JavaScript and +Node.js code, and it often demands special tooling to be able to do so. This tutorial shows how to set up a project +with Babel and Webpack, which allows you to write modern ES6 JavaScript code for the browser and the server. </p> + + + + JavaScript News and Resources - October 2017 + https://www.nodebeginner.org/blog/post/javascript-news-and-resources-october-2017/ + Sat, 07 Oct 2017 17:34:00 +0200 + + https://www.nodebeginner.org/blog/post/javascript-news-and-resources-october-2017/ + <p>The first issue of our monthly JavaScript ecosystem and community overview gets you covered with the most important reports, tutorials, and resources of the month. </p> + + + + Node.js tutorial: Super-fast web applications with the WebSocket protocol + https://www.nodebeginner.org/blog/post/nodejs-tutorial-how-to-work-with-websockets/ + Mon, 18 Sep 2017 18:21:17 +0200 + + https://www.nodebeginner.org/blog/post/nodejs-tutorial-how-to-work-with-websockets/ + <p>The WebSocket protocol is an extension to the HTTP ecosystem which allows to create live connections between a +web server and a web browser, enabling web applications to efficiently exchange data in real-time without the overhead +of conventional HTTP connections. Node.js is perfectly suited for writing WebSocket applications, and this tutorial +explains how it all works.</p> + + + + Explained: What are Node.js modules? + https://www.nodebeginner.org/blog/post/nodejs-tutorial-what-are-node.js-modules/ + Wed, 05 Jul 2017 21:52:56 +0200 + + https://www.nodebeginner.org/blog/post/nodejs-tutorial-what-are-node.js-modules/ + <p>When you write Node.js applications, you could actually put all your code into one huge <em>index.js</em> file, no matter +how large or complex your application is. The Node.js interpreter doesn&rsquo;t care. But in terms of code organization, +you would end up with a hard to understand and hard to debug mess quite quickly. So as a human being, you should care +about how to structure your code. This is where modules come in. </p> + + Node.js tutorial: Optimizing code performance using async https://www.nodebeginner.org/blog/post/nodejs-tutorial-optimizing-code-performance-using-async/ diff --git a/blog/page/1/index.html b/blog/page/1/index.html index fc39655..655e14d 100644 --- a/blog/page/1/index.html +++ b/blog/page/1/index.html @@ -1 +1 @@ -https://www.nodebeginner.org/blog/ \ No newline at end of file +https://www.nodebeginner.org/blog/ \ No newline at end of file diff --git a/blog/php.ini b/blog/php.ini new file mode 100644 index 0000000..3c452e2 --- /dev/null +++ b/blog/php.ini @@ -0,0 +1,5 @@ +short_open_tag=off +zlib.output_compression=1 +zlib.output_compression_level=9 +auto_prepend_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/header.php +auto_append_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/footer.php diff --git a/blog/post/index.html b/blog/post/index.html index 1b522b5..9eba275 100644 --- a/blog/post/index.html +++ b/blog/post/index.html @@ -4,12 +4,32 @@ - Posts · The Node Beginner Blog +Posts - The Node Beginner Blog + + + + + + + + + + + + + + + + + + + + - + @@ -23,13 +43,69 @@

The Node Beginner Blog

-

Node.js tutorials, how-to's, and more.

+

Your regularly updated tutorial resource for all things Node.js.

+
+

Setting up a JavaScript project for ES6 development with Babel and Webpack

+ + + +
+

JavaScript is a language and an ecosystem which constantly evolves. This changes the way we can write JavaScript and +Node.js code, and it often demands special tooling to be able to do so. This tutorial shows how to set up a project +with Babel and Webpack, which allows you to write modern ES6 JavaScript code for the browser and the server.

+ Read more +
+ +
+ +
+

JavaScript News and Resources - October 2017

+ + + +
+

The first issue of our monthly JavaScript ecosystem and community overview gets you covered with the most important reports, tutorials, and resources of the month.

+ Read more +
+ +
+ +
+

Node.js tutorial: Super-fast web applications with the WebSocket protocol

+ + + +
+

The WebSocket protocol is an extension to the HTTP ecosystem which allows to create live connections between a +web server and a web browser, enabling web applications to efficiently exchange data in real-time without the overhead +of conventional HTTP connections. Node.js is perfectly suited for writing WebSocket applications, and this tutorial +explains how it all works.

+ Read more +
+ +
+ +
+

Explained: What are Node.js modules?

+ + + +
+

When you write Node.js applications, you could actually put all your code into one huge index.js file, no matter +how large or complex your application is. The Node.js interpreter doesn’t care. But in terms of code organization, +you would end up with a hard to understand and hard to debug mess quite quickly. So as a human being, you should care +about how to structure your code. This is where modules come in.

+ Read more +
+ +
+

Node.js tutorial: Optimizing code performance using async

@@ -82,17 +158,6 @@

- - diff --git a/blog/post/index.xml b/blog/post/index.xml index 6f066dc..2a2a05b 100644 --- a/blog/post/index.xml +++ b/blog/post/index.xml @@ -6,11 +6,55 @@ Recent content in Posts on The Node Beginner Blog Hugo -- gohugo.io en-us - Tue, 06 Jun 2017 08:22:42 +0200 + Sun, 08 Oct 2017 09:18:00 +0200 + + Setting up a JavaScript project for ES6 development with Babel and Webpack + https://www.nodebeginner.org/blog/post/setting-up-a-javascript-project-for-es6-development-with-babel-and-webpack/ + Sun, 08 Oct 2017 09:18:00 +0200 + + https://www.nodebeginner.org/blog/post/setting-up-a-javascript-project-for-es6-development-with-babel-and-webpack/ + <p>JavaScript is a language and an ecosystem which constantly evolves. This changes the way we can write JavaScript and +Node.js code, and it often demands special tooling to be able to do so. This tutorial shows how to set up a project +with Babel and Webpack, which allows you to write modern ES6 JavaScript code for the browser and the server. </p> + + + + JavaScript News and Resources - October 2017 + https://www.nodebeginner.org/blog/post/javascript-news-and-resources-october-2017/ + Sat, 07 Oct 2017 17:34:00 +0200 + + https://www.nodebeginner.org/blog/post/javascript-news-and-resources-october-2017/ + <p>The first issue of our monthly JavaScript ecosystem and community overview gets you covered with the most important reports, tutorials, and resources of the month. </p> + + + + Node.js tutorial: Super-fast web applications with the WebSocket protocol + https://www.nodebeginner.org/blog/post/nodejs-tutorial-how-to-work-with-websockets/ + Mon, 18 Sep 2017 18:21:17 +0200 + + https://www.nodebeginner.org/blog/post/nodejs-tutorial-how-to-work-with-websockets/ + <p>The WebSocket protocol is an extension to the HTTP ecosystem which allows to create live connections between a +web server and a web browser, enabling web applications to efficiently exchange data in real-time without the overhead +of conventional HTTP connections. Node.js is perfectly suited for writing WebSocket applications, and this tutorial +explains how it all works.</p> + + + + Explained: What are Node.js modules? + https://www.nodebeginner.org/blog/post/nodejs-tutorial-what-are-node.js-modules/ + Wed, 05 Jul 2017 21:52:56 +0200 + + https://www.nodebeginner.org/blog/post/nodejs-tutorial-what-are-node.js-modules/ + <p>When you write Node.js applications, you could actually put all your code into one huge <em>index.js</em> file, no matter +how large or complex your application is. The Node.js interpreter doesn&rsquo;t care. But in terms of code organization, +you would end up with a hard to understand and hard to debug mess quite quickly. So as a human being, you should care +about how to structure your code. This is where modules come in. </p> + + Node.js tutorial: Optimizing code performance using async https://www.nodebeginner.org/blog/post/nodejs-tutorial-optimizing-code-performance-using-async/ diff --git a/blog/post/javascript-news-and-resources-october-2017/index.html b/blog/post/javascript-news-and-resources-october-2017/index.html new file mode 100644 index 0000000..a7cbf88 --- /dev/null +++ b/blog/post/javascript-news-and-resources-october-2017/index.html @@ -0,0 +1,164 @@ + + + + + + +JavaScript News and Resources - October 2017 - The Node Beginner Blog + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

The Node Beginner Blog

+

Your regularly updated tutorial resource for all things Node.js.

+ + +
+
+
+
+

JavaScript News and Resources - October 2017

+ +
+

The first issue of our monthly JavaScript ecosystem and community overview gets you covered with the most important reports, tutorials, and resources of the month.

+ +

New tutorials

+ +

Setting up a JavaScript project for ES6 development with Babel and Webpack

+ +

From our own blog, this tutorial explains how to set up a JavaScript project for ES6 development with Babel and +Webpack.

+ +

async/await

+ +

Nikolay Grozev has written a thorough and visual tutorial on the +async/await syntax that comes with JavaScript ES7.

+ +

Protect your npm account

+ +

On their blog, the NPM project explains how to protect your npm account with two-factor authentication and read-only +tokens.

+ +

How to write reliable browser tests using Selenium and Node.js

+ +

Todd Chaffee gets you through all the details and pitfalls of how to test your web +applications with JavaScript.

+ +

Super-fast web applications with the WebSocket protocol

+ +

Again from our own blog, this tutorial explains how to massively improve data exchange between browsers and your Node.js +server application by utilizing the WebSocket protocol.

+ +

API Authentication With Node.js

+ +

Building APIs is important; however, building secured APIs is also very important. +In this tutorial, you learn how to build a secured API in Node.js.

+ +

Configuring Your .npmrc for an Optimal Node.js Environment

+ +

One of the most useful, important, and enabling aspects of the npm CLI is that its highly configurable. This article +explains how to exploit this to use NPM effectively.

+ +

Vue.js vs React: Which JavaScript framework to choose for your project?

+ +

The folks at da14 provide a nice guide to help you with your decision.

+ +

In the news

+ +

Node.js v8.6.0 has been released

+ +

This is a new minor release for the current stable version. As always, download here.

+ +

Notable Changes:

+ +
    +
  • crypto: Support for multiple ECDH curves.
  • +
  • dgram: Added setMulticastInterface() API. Custom lookup functions are now supported.
  • +
  • n-api The command-line flag is no longer required to use N-API.
  • +
  • tls Docs-only deprecation of parseCertString().
  • +
+ +

React v16.0 has been released

+ +

Featuring two new render return types (fragments and strings), improved error handling and server-side rendering, +portals, support for custom DOM attributes, and - gasp - it’s MIT licensed. Read all about it in this Facebook post.

+ +

Typescript turns 5 years old

+ +

On October 1, 2012, Microsoft released TypeScript. +Here is a blog post where they look back at its 5 years of history.

+ + + +

In 1993, Dan Linton, owner of a hugely successful BBS called Software Creations, visited Texas and made his way to id +Software. This is the footage he recorded one night in November 1993.

+ +
+ +
+

Learn more about writing web applications using Node.js +with The Node Beginner Book - the first part of this step-by-step Node.js tutorial +is available for free!

+
+
+
+ +
+
+ + + +
+ + + + + + + diff --git a/blog/post/node-v8_0_0-released/index.html b/blog/post/node-v8_0_0-released/index.html index 24a474f..0b08619 100644 --- a/blog/post/node-v8_0_0-released/index.html +++ b/blog/post/node-v8_0_0-released/index.html @@ -4,12 +4,32 @@ - Node.js 8.0.0 has been released · The Node Beginner Blog +Node.js 8.0.0 has been released - The Node Beginner Blog + + + + + + + + + + + + + + + + + + + + - + @@ -23,7 +43,7 @@

The Node Beginner Blog

-

Node.js tutorials, how-to's, and more.

+

Your regularly updated tutorial resource for all things Node.js.

@@ -39,12 +59,15 @@

the official download page.

-

If you want to learn the ins and outs of Node.js and become a proficient Node.js -software developer quickly, check out my two-book bundle, The Node Beginner Book and The Node Craftsman Book. You can read the first part for free right here.

+

If you want to learn the ins and outs of Node.js and become a proficient Node.js +software developer quickly, check out my two-book bundle, The Node Beginner Book and The Node Craftsman Book. You can read the first part for free right here.

@@ -61,16 +84,6 @@

+ +Node.js tutorial: Super-fast web applications with the WebSocket protocol - The Node Beginner Blog + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

The Node Beginner Blog

+

Your regularly updated tutorial resource for all things Node.js.

+ + +
+
+
+
+

Node.js tutorial: Super-fast web applications with the WebSocket protocol

+ +
+

The WebSocket protocol is an extension to the HTTP ecosystem which allows to create live connections between a +web server and a web browser, enabling web applications to efficiently exchange data in real-time without the overhead +of conventional HTTP connections. Node.js is perfectly suited for writing WebSocket applications, and this tutorial +explains how it all works.

+ +

Where WebSocket connections beat HTTP connections

+ +

The HTTP protocol obviously does a great job at enabling data exchange between a webserver and a browser, hence the +extraordinary success of the World Wide Web. So why does the Web need another protocol? It’s two aspects that are +relevant here: bi-directionality and real-time.

+ +

HTTP connections: neither bi-directional nor real-time

+ +

The “conventional” Web, built on HTTP, is based on a client-server model with the client (the web browser) in the lead.

+ +

Conventional HTTP web servers do nothing on their own without being explicitly asked by a client. Getting some kind +of information - for example, the current price of a stock, in the form of a web page with stock market information - +requires the browser to actively ask the server for that information, e.g. by issueing a GET request to the web page +at, say, http://stocks.example.com/company/apple-inc.

+ +

This is only triggered by a human user who decides to visit this page. If this user wants to learn the most recent stock +price again at a later point in time, he or she has to reload the page.

+ +

If the webpage wants to supply the most recent stock price to the user regularly without requiring the user to manually +reload the page, then workarounds exist. The most common workaround is to run some JavaScript code in the webpage which +regularly “polls” a webservice from the server which responds with the current stock price, via AJAX. If the new stock +price is different from the one on the page, then the client-side JavaScript code can update the webpage content and +present the new price to the user.

+ +

This improves the interactivity of the site, but it is not optimal: If stock price updates need to be reported to the +user as soon as possible, the JavaScript code needs to query the webservice with high frequency - for example, every +5 seconds. And if the requirement is to inform the user about a stock price change no later than 1 second after the +change occured, then a new request must be send to the server every second.

+ +

But that’s not a real solution to the requirement of getting the info from the server proactively - you are just asking +very often, which isn’t exactly efficient. Imagine that there is no stock price change for 10 minutes. That’s 600 HTTP +requests from the client to the webserver with no useful results at all. That is wasting a lot of traffic and computing +resources on both the client and the server.

+ +

Also, there’s a limit to the frequency at which the client can ask the server for new content. Using AJAX, you can get +near-time updates from the server to the client, but doing real-time updates efficiently is out of the question.

+ +

This is why until now, complex applications which update many different information on the screen fluidly and in +real-time are seldom seen on the web and are usually implemented as full-fledged desktop applications. But the WebSocket +protocol is about to change this.

+ +

WebSocket connections: putting the webserver in the lead

+ +

The important conceptual change that the WebSocket protocol brings to the table is that it allows the client +to establish a connection with the web server which a) stays open as long as the web page is opened in the browser, and +which b) the web server can actively use to send data to the client whenever the server wants to, without being asked by +the client to do so.

+ +

Thus, in addition to the client-server model of HTTP, we now have a model of a truly bi-directional connection, with +both partners of the connection being equal.

+ +

As a result, this allows for data exchange that is much more efficient and happens real-time. In our stock price +example, the server can “push” a stock price update over the connection as soon as it occurs, and only if and when it +occurs. If there is no stock price update for 10 minutes, then the exchanged data during these 10 minutes is zero. And +when the update finally occurs, the client learns about it immediately, and not when it happens to ask.

+ +

How WebSocket connections work

+ +

Conceptually, the WebSocket protocol is an extension to HTTP which allows clients to “upgrade” an HTTP connection with +an additional bi-directional connection which remains established, like this:

+ +
    +
  • Client opens HTTP connection to server and asks for document
  • +
  • Server responds with an HTML document
  • +
  • HTTP connection is closed
  • +
  • JavaScript code in the HTML document opens another HTTP connection in which it asks the server to upgrade this +connection to a WebSocket connection
  • +
  • A WebSocket connection between client and server is established and remains open for sending and receiving data in +both directions
  • +
+ +

Technically, a WebSocket connection is simply a TCP connection on port 80, just like normal HTTP connections are - +with the difference that client and server treat the connection in a special way.

+ +

Creating a WebSocket connection from an HTTP connection requires knowledge about the details of the HTTP and WebSocket +protocols, but luckily, easy-to-use libraries exist which provide a nice and straightforward abstraction of these +details both on the server and the client side. We will look at how to use these in Node.js now.

+ +

How to use WebSocket connections in your web application

+ +

By now we learned that the client-side JavaScript code on a webpage needs to intitiate a WebSocket connection, and +the server-side code needs to handle such a request accordingly. Thus, specialised client and server code is neccessary.

+ +

How do we get there?

+ +

When working with Node.js, it’s not difficult at all. The most straightforward and +efficient approach is to use a JavaScript library which provides the neccessary methods for both sides - a client part +which is executed by the user’s web browser, and a server part which runs within an existing Node.js HTTP server.

+ +

The most mature and most popular library for this is Socket.io. Let’s use this to write a simple +WebSocket stock price ticker application.

+ +

As said, we need to take care of both the client side and the server side to get a WebSocket application up and running. +We start with the server side, which we’ll of course implement using Node.js.

+ +

From a Node.js perspective, Socket.io is simply an NPM library. However, we are not going to install it just yet. +Socket.io doesn’t work on it’s own - it is not a full-fledged Node.js webserver or web application framework. It needs +a webserver or framework to integrate with, and we’ll set that up first, using the popular Node.js web framework +Express.js.

+ +

To do so, create a new project folder called websocket-test, and create the following package.json inside:

+ +
{
+  "name": "websocket-stock-ticker",
+  "version": "0.0.1",
+  "description": "WebSocket Stock Ticker",
+  "dependencies": {}
+}
+
+ +

Then, pull in Express.js via NPM: npm install --save express.

+ +

You can now create a very basic Express.js based HTTP webserver, in file index.js:

+ +
var app = require('express')();
+var http = require('http').Server(app);
+
+app.get('/', function(req, res) {
+  res.sendFile(__dirname + '/index.html');
+});
+
+http.listen(8000, function() {
+  console.log('Listening on *:8000');
+});
+
+ +

This creates an HTTP webserver listening on port 8000, which serves file index.html through the Express.js route +handler when requested at path /.

+ +

However, file index.html does not yet exist, so let’s create that in the same folder:

+ +
<!doctype html>
+<html>
+  <head>
+    <title>Live stock price ticker</title>
+  </head>
+  <body>
+    Stock price: <span id="stockprice">no data yet</span>
+  </body>
+</html>
+
+ +

If you start the application with node index.js and open address http://localhost:8000 in your browser, you are +going to see a very basic web page which shows Stock price: no data yet as its content.

+ +

We have laid the foundation for our live stock price ticker application, but that no data yet part of the web page +needs to be updated regularly with the most current stock price, and this of course will be done through a WebSocket +connection between the page on the client side and our Node.js server.

+ +

As stated above, it is the client that has to initiate a WebSocket connection. Right now, we do not yet have any +JavaScript in our web page which could do that, so let’s change that.

+ +

To do so, we need to integrate the client-side part of Socket.io into our page. For a real and production-ready +environment, we would probably want to download and integrate this library - called socket.io-client - ourselves, but +for getting a quick prototype of our application up and running, it’s sufficient to let our server-side code serve the +client-side library automatically.

+ +

This is achieved by installing and integrating the server-side part of Socket.io into our Node.js application.

+ +

Installation is done by running npm install --save socket.io, and afterwards, we can integrate it with our Express.js +server:

+ +
var app = require('express')();
+var http = require('http').Server(app);
+var io = require('socket.io')(http);
+
+app.get('/', function(req, res) {
+  res.sendFile(__dirname + '/index.html');
+});
+
+io.on('connection', function(socket){
+  console.log('A new WebSocket connection has been established');
+});
+
+http.listen(8000, function() {
+  console.log('Listening on *:8000');
+});
+
+ +

This pulls a Socket.io object into our code in variable io. It is immediately integrated with our Express http +server object - Socket.io knows how to hook into an Express.js server out of the box, so we don’t need to do any +integration work ourselves.

+ +

This integration also results in the creation of a new Express.js route - when our webserver is requested at +http://localhost:8000/socket.io/socket.io.js, it serves the client-side Socket.io library. Again, this is nothing we +have to do ourselves in our own code. The line var io = require('socket.io')(http); takes care of this automatically +and behind the scenes.

+ +

What we do have to code ourselves is to add an event listener which handles events from the WebSocket connection.

+ +

For now, we only react to the event that is triggered when a new client establishes a WebSocket connection. To do so, +we attach an anonymous function to the connection event emitted my the io object. We use it to generate log output.

+ +
+

Learn all about Event Listeners and Event Emitters from my new book, +The Node Craftsman Book. It comes +bundled with The Node Beginner Book, and both together are +now available via Leanpub for only $9.

+
+ +

If you restart the Node.js server and again load page http://localhost:8000 in your browser, nothing new happens.

+ +

This is because our web page does not yet open up a WebSocket connection. We need to code this now, in file +index.html:

+ +
<!doctype html>
+<html>
+  <head>
+    <title>Live stock price ticker</title>
+
+    <script src="/socket.io/socket.io.js"></script>
+    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
+
+    <script>
+      $(function () {
+        var socket = io();
+      });
+    </script>
+
+  </head>
+  <body>
+    Stock price: <span id="stockprice">no data yet</span>
+  </body>
+</html>
+
+ +

As you can see, we load the Socket.io client library which is now provided by the Socket.io server library. Note that we +also pull in jQuery - this is not strictly neccessary, but it makes it easier to manipulate the web page content.

+ +

If again you reload the web page (no need to restart the server here), you will now see +“A new WebSocket connection has been established” being outputted by the server.

+ +

With this, everything is in place to actively push data from the server to the web page. Let’s do this now.

+ +

Again, we start on the server side. We do not have real stock prices, so we will just generate a new random stock price +value every second for each client that connects, and push it out to all connected clients:

+ +
var app = require('express')();
+var http = require('http').Server(app);
+var io = require('socket.io')(http);
+
+app.get('/', function(req, res) {
+    res.sendFile(__dirname + '/index.html');
+});
+
+io.on('connection', function(socket) {
+    console.log('A new WebSocket connection has been established');
+});
+
+setInterval(function() {
+  var stockprice = Math.floor(Math.random() * 1000);
+  io.emit('stock price update', stockprice);
+}, 1000);
+
+http.listen(8000, function() {
+    console.log('Listening on *:8000');
+});
+
+ +

The key function here is io.emit - Socket.io tracks all client connections internally, and emit sends out a message +to all these clients. This is the most simple way to get data from the WebSocket server to the WebSocket clients, but +for our demo application it’s good enough.

+ +

Each message sent via emit has an event name - in our case, that’s stock price update - and a value, which is the +new stock price we calculated. We can make up event names on the fly - we just need to make sure that clients work with +the same event names to make them useful. And we can send any basic JavaScript values, like strings, booleans, numbers, +arrays, objects etc.

+ +

We don’t need to do anything on the client side to make the WebSocket client receive these messages, but we need to +extend our code if we want to make the client do anything useful with it. In this case, let’s update the stock price +display whenever a new message arrives. By combining Socket.io and jQuery, this is difficult:

+ +
<!doctype html>
+<html>
+  <head>
+    <title>Live stock price ticker</title>
+
+    <script src="/socket.io/socket.io.js"></script>
+    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
+
+    <script>
+      $(function () {
+        var socket = io();
+
+        socket.on('stock price update', function(stockprice) {
+          $('#stockprice').text(stockprice);
+        });
+
+      });
+    </script>
+
+  </head>
+  <body>
+    Stock price: <span id="stockprice">no data yet</span>
+  </body>
+</html>
+
+ +

As you can see, we have added an event listener on the socket object right after we created it. This listener reacts +to all received messages whose event name is stock price update. Attached to the event listener is an anonymous +function which receives the value part of the message whenever the listener triggers it - in our case, we know that this +value is the latest stock price.

+ +

We then use this value to update the text content of the <span> element with id stockprice, using jQuery.

+ +

If you reload the updated page, you still see the no data yet text for a moment, but then the stock price updates are +reflected on the page each seconds. If you open multiple browser windows or tabs, you should see the same stock price +value being displayed and updated at the same time.

+ +

An update cycle of 1000 ms still feels very “normal HTTP-ish” - let’s prove how WebSocket connections can really make +server-side updates to web page contents feel much smoother, by changing our server code to this:

+ +
var app = require('express')();
+var http = require('http').Server(app);
+var io = require('socket.io')(http);
+
+app.get('/', function(req, res) {
+    res.sendFile(__dirname + '/index.html');
+});
+
+io.on('connection', function(socket) {
+    console.log('A new WebSocket connection has been established');
+});
+
+setInterval(function() {
+  var stockprice = Math.floor(Math.random() * 1000);
+  io.emit('stock price update', stockprice);
+}, 50);
+
+http.listen(8000, function() {
+    console.log('Listening on *:8000');
+});
+
+ +

The only change is the setInterval timing, from 1000 ms to 50 ms. When you restart the server and again open the web +page in multiple browser windows, you can see the efficiency and performance of WebSocket applications in action.

+ +
+ +
+

Learn more about writing web applications using Node.js +with The Node Beginner Book - the first part of this step-by-step Node.js tutorial +is available for free!

+
+
+
+ +
+
+ + + +
+ + + + + + + diff --git a/blog/post/nodejs-tutorial-optimizing-code-performance-using-async/index.html b/blog/post/nodejs-tutorial-optimizing-code-performance-using-async/index.html index 385ac79..39330ae 100644 --- a/blog/post/nodejs-tutorial-optimizing-code-performance-using-async/index.html +++ b/blog/post/nodejs-tutorial-optimizing-code-performance-using-async/index.html @@ -4,12 +4,32 @@ - Node.js tutorial: Optimizing code performance using async · The Node Beginner Blog +Node.js tutorial: Optimizing code performance using async - The Node Beginner Blog + + + + + + + + + + + + + + + + + + + + - + @@ -23,7 +43,7 @@

The Node Beginner Blog

-

Node.js tutorials, how-to's, and more.

+

Your regularly updated tutorial resource for all things Node.js.

@@ -80,7 +100,7 @@

making Node.js applications perform efficiently - reading a large file or writing a lot of records to a database will always be a costly procedure, but handling it asynchronously at least ensures that the other parts of our application won’t be blocked while that procedure is going on.

@@ -93,9 +113,10 @@

Executing

Let’s consider an example where our application queries several different remote web services, presenting the retrieved data on the console.

-

We are not going to query real remote web services, instead we will write a very -simple Node.js HTTP server that will serve as a dummy web service. Our web server -doesn’t really do anything significant, and therefore we will make it react to +

We are not going to query real remote web services, instead we will +write a very simple Node.js HTTP server +that will serve as a dummy web service. +Our web server doesn’t really do anything significant, and therefore we will make it react to requests a bit slower than neccessary, in order to simulate a real web service that has a certain workload - as you will see, this makes it easier for us to show the performance gain in our own code optimizations.

@@ -135,9 +156,9 @@

Executing

This gives us a very simple “echo” server - if we request the URL -http://localhost:8080/getUser?id=4, we receive +h⁣ttp://localhost:8080/getUser?id=4, we receive {"pathname":"/getUser","id":"4","value":67} as the response. This is good enough to -give us the simulation of a remote webservice API to play around with.

+give us the simulation of a remote webservice API to play around with.

But alas, it’s a slow webservice! Someone didn’t do his optimization homework, and we now have to deal with an API where every response takes between 2 to 3 seconds @@ -146,7 +167,7 @@

Executing

This allows to show how different request patterns will result in different runtime characteristics.

-

We will now write a Node.js client for this webserver. This client will make two +

We will now write a Node.js client for this webserver. This client will make two consecutive requests to the server, and print the output for both requests on the command line:

@@ -308,7 +329,7 @@

Executing

async is a clever little module that makes managing complex control flows in our code a breeze.

-

After installing the module via npm install async@2.1.4, we can write our client like +

After installing the module via npm install async@2.1.4, we can write our client like this:

'use strict';
@@ -376,11 +397,11 @@ 

Executing

Optimizing code structure with async

-

async offers several other mechanisms for managing the control flow of our code. +

async offers several other mechanisms for managing the control flow of our code. These are interesting even if our concern isn’t performance optimization. Let’s investigate them.

-

For these cases, let’s remove the artificial slowness from the API server +

For these cases, let’s remove the artificial slowness from our https://www.nodebeginner.org/#a-basic-http-server by removing the setTimeout operation on line 19 and 22, making the server respond immediately:

@@ -607,14 +628,14 @@

Optimizing code structure with
  • Working with NPM and Packages
  • -
  • Object-oriented JavaScript
  • +
  • Object-oriented JavaScript
  • Test-Driven Node.js Development
  • Synchronous and Asynchronous operations explained
  • Using and creating Event Emitters
  • Node.js and MySQL
  • Node.js and MongoDB
  • Writing fast and efficient code
  • -
  • Writing a REST webservice application
  • +
  • Writing a REST webservice application
  • Combining Node.js and AngularJS
  • Setting up a continuous deployment workflow
  • @@ -623,8 +644,13 @@

    Optimizing code structure with , and both books together are available from Leanpub for only $9.00.

    -

    @@ -641,16 +667,6 @@

    Optimizing code structure with hljs.initHighlightingOnLoad(); - diff --git a/blog/post/nodejs-tutorial-what-are-node.js-modules/index.html b/blog/post/nodejs-tutorial-what-are-node.js-modules/index.html new file mode 100644 index 0000000..dac3a70 --- /dev/null +++ b/blog/post/nodejs-tutorial-what-are-node.js-modules/index.html @@ -0,0 +1,195 @@ + + + + + + +Explained: What are Node.js modules? - The Node Beginner Blog + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +

    The Node Beginner Blog

    +

    Your regularly updated tutorial resource for all things Node.js.

    + + +
    +
    +
    +
    +

    Explained: What are Node.js modules?

    + +
    +

    When you write Node.js applications, you could actually put all your code into one huge index.js file, no matter +how large or complex your application is. The Node.js interpreter doesn’t care. But in terms of code organization, +you would end up with a hard to understand and hard to debug mess quite quickly. So as a human being, you should care +about how to structure your code. This is where modules come in.

    + +

    You can think of Node.js modules as JavaScript libraries - a certain part of your overall codebase (for example, a +collection of functions) which you want to keep together, but which you also want to keep separated from the rest of +your codebase to keep things cleanly separated.

    + +

    Just like we keep our socks in one drawer and our shirts in another drawer in our wardrobe - even if we combine +both to create an outfit for the day - we can keep different parts of our codebase in different modules and then combine +them into a coherent application.

    + +

    Built-in Modules

    + +

    Even if we don’t create any Node.js modules ourselves, we already have modules at our disposal because the Node.js +environment provides built-in modules for us. We already encountered one of these modules in this blog when we looked at +how to use the built-in WHATWG URL parser.

    + +

    Within our own code file, we needed to use existing code which was declared elsewhere - in this case, the URL class +which is part of the built-in Node.js module url:

    + +
    var URL = require('url').URL;
    +
    + +

    The require('url') part is what gives us access to the code of the url module. Where and how this module is defined +is completely opaque for us - all we need to know is its name - url - and the attributes it exposes, like URL.

    + +

    Other built-in modules directly expose the attribute we need (which often are JavaScript objects). The http module is +an example:

    + +
    var http = require('http');
    +
    +http.createServer(function (req, res) {
    +    res.writeHead(200, {'Content-Type': 'text/html'});
    +    res.end('Hello World!');
    +}).listen(8080);
    +
    + +

    Here, requiring the http module gives us direct access to an http object, whose methods, like createServer, we can +then use.

    + +

    The Node Beginner Book explains how to write a complete web server with Node.js +using the built-in http module.

    + +

    External Modules

    + +

    The built-in modules which ship with Node.js allow to solve a lot of coding problems without reinventing the wheel for +every new application, but what really boosts Node.js programming productivity is the huge ecosystem of open source +modules provided by the Node.js community. These modules can be integrated into our codebase, too, but because they are +not built-in and don’t ship directly with each installation of Node.js, it is not enough to require them from our own +code. We need to install the codebase containing the external module locally first, which is made very easy thanks to +NPM, the Node Package Manager.

    + +

    See this blog post which describes +how to use the async library for an +example of how to use external modules.

    + +

    Also, The Node Craftsman Book has a chapter on the details of +working with NPM.

    + +

    Creating your own modules

    + +

    Built-in and external modules are provided by others, but nothing stops you from creating your own Node.js modules.

    + +

    The following example creates a module myRandom which provides a helper function that returns random number between 1 +and 10:

    + +

    File myRandom.js:

    + +
    function getRandom(min, max) {
    +      return Math.random() * (max - min) + min;
    +}
    +
    +exports.between1and10 = function() {
    +      return getRandom(1, 10);
    +};
    +
    + +

    You would put this code into it’s own file called myRandom.js. Because this file exists and provides attributes to the +outer world via exports, another file index.js can use the exported functionality:

    + +

    File index.js:

    + +
    var myRandom = require('./myRandom.js');
    +
    +console.log(myRandom.between1and10());
    +
    + +

    Again, require comes into play, making the exported attributes of the local myRandom module available - in this +case, the between1and10 function.

    + +

    Note: While the module system allows to expose functionality of a module, it also allows to hide functionality which +is not needed outside of the module, simply by not exporting the functionality via exports. Even though the index.js +file has required the myRandom.js file, it cannot access its non-exported getRandom function:

    + +
    var myRandom = require('./myRandom.js');
    +
    +console.log(myRandom.getRandom(5, 99));
    +
    + +

    will result in a TypeError: myRandom.getRandom is not a function.

    + +

    By hiding implementation details in a module and only exposing those parts which are to be used by other parts of your +codebase, you can keep your codebase well organized.

    + +
    + +

    Learn more about working with modules and building your own web server +application with Node.js with The Node Beginner Book - the first part of this +step-by-step Node.js tutorial is available for free!

    +
    +
    + +
    +
    + + + +
    + + + + + + + diff --git a/blog/post/nodejs-tutorial-whatwg-url-parser/index.html b/blog/post/nodejs-tutorial-whatwg-url-parser/index.html index e52aec0..f6da596 100644 --- a/blog/post/nodejs-tutorial-whatwg-url-parser/index.html +++ b/blog/post/nodejs-tutorial-whatwg-url-parser/index.html @@ -4,12 +4,32 @@ - Node.js tutorial: The WHATWG URL parser · The Node Beginner Blog +Node.js tutorial: The WHATWG URL parser - The Node Beginner Blog + + + + + + + + + + + + + + + + + + + + - + @@ -23,7 +43,7 @@

    The Node Beginner Blog

    -

    Node.js tutorials, how-to's, and more.

    +

    Your regularly updated tutorial resource for all things Node.js.

    @@ -56,15 +76,15 @@

    the first part of this extensive tutorial is available for free!

    +

    Learn more about working with URLs and building your own web server application with Node.js with The Node Beginner Book - the first part of this extensive Node.js tutorial is available for free!

    @@ -103,16 +127,6 @@

    \ No newline at end of file +https://www.nodebeginner.org/blog/post/ \ No newline at end of file diff --git a/blog/post/php.ini b/blog/post/php.ini new file mode 100644 index 0000000..3c452e2 --- /dev/null +++ b/blog/post/php.ini @@ -0,0 +1,5 @@ +short_open_tag=off +zlib.output_compression=1 +zlib.output_compression_level=9 +auto_prepend_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/header.php +auto_append_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/footer.php diff --git a/blog/post/setting-up-a-javascript-project-for-es6-development-with-babel-and-webpack/index.html b/blog/post/setting-up-a-javascript-project-for-es6-development-with-babel-and-webpack/index.html new file mode 100644 index 0000000..b6591ae --- /dev/null +++ b/blog/post/setting-up-a-javascript-project-for-es6-development-with-babel-and-webpack/index.html @@ -0,0 +1,481 @@ + + + + + + +Setting up a JavaScript project for ES6 development with Babel and Webpack - The Node Beginner Blog + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +

    The Node Beginner Blog

    +

    Your regularly updated tutorial resource for all things Node.js.

    + + +
    +
    +
    +
    +

    Setting up a JavaScript project for ES6 development with Babel and Webpack

    + +
    +

    JavaScript is a language and an ecosystem which constantly evolves. This changes the way we can write JavaScript and +Node.js code, and it often demands special tooling to be able to do so. This tutorial shows how to set up a project +with Babel and Webpack, which allows you to write modern ES6 JavaScript code for the browser and the server.

    + +

    The example project setup

    + +

    In the course of this tutorial, we are going to create a Node.js HTTP server with ES6 JavaScript code, and this server +in turn serves a web page which loads a ES6 JavaScript application in the browser. Together, it’s not much more than a +“Hello World” application, but it’s enough to force us to go full circle with our ES6 development setup.

    + +

    Now, it’s not enough to write ES6-level JavaScript code to get this demo application running. That’s because neither +Node.js nor our browser will support all ES6 features of the code we are going write.

    + +

    This is why we need extra tooling, namely Babel and Webpack.

    + +

    Instead of explaining what these do in detail beforehand, we will write our server and client application code using ES6 +syntax, see how that fails to work out of the box, and then bring in Babel and Webpack to save the day - while also +explaining how they work.

    + +

    In the course of this tutorial, we will create the following project structure:

    + +
    es6-demo
    +├── .babelrc
    +├── package.json
    +├── webpack.config.js
    +├── src
    +│   ├── backend
    +│   │   └── server.js
    +│   └── frontend
    +│       └── index.js
    +└── dist
    +    ├── index.html
    +    └── build.js
    +
    + +

    The famous node_modules folder is not shown here, but will of course be created once we start installing packages +with NPM.

    + +

    Building the app

    + +

    We start on the server-side. Create the following folders:

    + +
    mkdir -p es6-demo/src/backend
    +mkdir -p es6-demo/src/frontend
    +mkdir -p es6-demo/dist
    +
    + +

    Within project root folder es6-demo, run npm init, and answer all question with the default.

    + +

    Then, within es6-demo/dist, create file index.html with the following content:

    + +
    <!DOCTYPE html>
    +<html>
    +    <head>
    +        <meta charset="UTF-8">
    +        <title>ES6 Demo Application</title>
    +    </head>
    +    <body>
    +        <div id="content">Client code has not yet replaced the content.</div>
    +
    +        <script src="bundle.js"></script>
    +    </body>
    +</html>
    +
    + +

    We need to serve this file when someone opens our application at http://127.0.0.1:8080. For this, we write a small +Node.js HTTP server in file es6-demo/src/backend/server.js - and we do so using ES6 JavaScript:

    + +
    import http from 'http';
    +import fs from 'fs';
    +import path from 'path';
    +
    +const indexHtmlContent = fs.readFileSync(path.join(__dirname, '/../../dist/index.html'));
    +
    +http.createServer((req, res) => {
    +  if (req.url === '/') {
    +    res.writeHead(200, { 'Content-Type': 'text/html' });
    +    res.end(indexHtmlContent);
    +  } else {
    +    res.writeHead(404, { 'Content-Type': 'text/plain' });
    +    res.end('Not found');
    +  }
    +}).listen(8080);
    +
    +console.log('Server running at http://127.0.0.1:8080/');
    +
    + +

    This looks a lot like the JavaScript code we know, but we can spot several ES6-specific parts:

    + +

    import instead of require

    + +

    Out of the box, the Node.js module system is based on CommonJS, a very straightforward module loader which utilizes +the require keyword - thus, pre-ES6 code would look like this:

    + +
    var http = require('http'); 
    +var fs = require('fs'); 
    +var path = require('path'); 
    +
    + +

    ES6, on the other hand, works with the import keyword.

    + +

    const variable desclaration

    + +

    Whereas pre-ES6 JavaScript only knows variable name declarations using var, ES6 supports the keyword const - it +should be used to declare a variable that is assigned a value only once, and then not changed or reassigned again.

    + +

    Arrow function expression using =>

    + +

    When we create an HTTP server in Node.js using the createServer method of the http object, we need to pass a +function that will be triggered whenever an HTTP request is received by our server.

    + +

    Pre-ES6, the notation for this looks as follows:

    + +
    http.createServer(function(req, res) {
    +  res.writeHead(200, { 'Content-Type': 'text/plain' });
    +  res.end('Hello, World.');
    +}).listen(8080);
    +
    + +

    With the new ES6 arrow function expression, we can be more concise:

    + +
    http.createServer((req, res) => {
    +  res.writeHead(200, { 'Content-Type': 'text/plain' });
    +  res.end('Hello, World.');
    +}).listen(8080);
    +
    + +

    Running the ES6 server

    + +

    The interesting question is: will this code run using the default Node.js interpreter (v8.6.0 as of this writing)?

    + +

    Let’s give it a try:

    + +
    $ > node ./src/backend/server.js
    +es6-demo/src/backend/server.js:1
    +(function (exports, require, module, __filename, __dirname) { import http from 'http';
    +                                                              ^^^^^^
    +
    +SyntaxError: Unexpected token import
    +    at createScript (vm.js:74:10)
    +    ...
    +
    + +

    No, it doesn’t. Node.js does not (yet) support the new ES6 module system, and bails out at the import keyword which it +simply doesn’t know.

    + +

    We now need to introduce Babel into the mix to make this code run. Babel helps us because it is a transpiler. Let’s +first clarify what that does NOT mean: Babel is NOT an extension to Node.js - it doesn’t “enhance” our Node.js +installation by teaching it ES6. Instead of changing Node.js, Babel changes our code. It transpiles our ES6 code into +code that follows the JavaScript language level that Node.js knows, that is, the ES6 predecessor (which is called +ECMAScript 5th edition, or ES5).

    + +

    Here is how our ES6 server.js file content looks after it went through Babel’s transpiling process:

    + +
    'use strict';
    +
    +var _http = require('http');
    +
    +var _http2 = _interopRequireDefault(_http);
    +
    +var _fs = require('fs');
    +
    +var _fs2 = _interopRequireDefault(_fs);
    +
    +var _path = require('path');
    +
    +var _path2 = _interopRequireDefault(_path);
    +
    +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
    +
    +var indexHtmlContent = _fs2.default.readFileSync(_path2.default.join(__dirname, '/../../dist/index.html'));
    +
    +_http2.default.createServer(function (req, res) {
    +  if (req.url === '/') {
    +    res.writeHead(200, { 'Content-Type': 'text/html' });
    +    res.end(indexHtmlContent);
    +  } else {
    +    res.writeHead(404, { 'Content-Type': 'text/plain' });
    +    res.end('Not found');
    +  }
    +}).listen(8080);
    +
    +console.log('Server running at http://127.0.0.1:8080/');
    +
    + +

    While not looking exactly like the pre-ES6 code we would write by hand, we can clearly see how the import and const +keywords are gone, and the fancy arrow function syntax is transpiled back into a good old anonymous function +declaration.

    + +

    This code can then be interpreted by Node.js.

    + +

    How do we get there? We start by installing some Babel-related NPM modules:

    + +
    npm install --save-dev babel-cli babel-preset-env
    +
    + +

    babel-cli is just a command line tool and some basic stuff that doesn’t do any actual transpilation. We need +babel-preset-env, which is a bundle of several different Babel plugins which, at +its core, gives us ES6-to-ES5 transpilation.

    + +

    We need to configure Babel by creating the following .babelrc file in the root folder of our project:

    + +
    {
    +  "presets": ["env"]
    +}
    +
    + +

    One way to use Babel in our project would be to simply transpile each ES6 code file we write by hand into its ES5 +equivalent, and then start the transpiled file with Node.js, like this:

    + +
    $> ./node_modules/.bin/babel src/backend/server.js > src/backend/server.es5.js
    +$> node src/backend/server.es5.js
    +Server running at http://127.0.0.1:8080/
    +
    + +

    This works, but is tiresome and error-prone. Babel makes this a lot easier for us by providing babel-node, a +command-line tool which we can use directly to launch Node.js with our ES6 code file. Behind the scenes, Babel +transpiles our code and feeds the result to Node.js:

    + +
    $> ./node_modules/.bin/babel-node src/backend/server.js
    +Server running at http://127.0.0.1:8080/
    +
    + +

    So, Node.js backend server code and ES6: Check. On to the frontend!

    + +

    Building and serving the frontend code for the browser

    + +

    Next, we need to write, build, and serve some ES6 JavaScript code for the browser.

    + +

    Our index.html file, which is now served by our Node.js backend server code, already has the line needed to kick off +a JavaScript application in the client:

    + +
    <script src="bundle.js"></script>
    +
    + +

    However, there is no bundle.js file yet - and actually, we are not going to write it. Instead, we write our own ES6 +client code in file frontend/index.js, and the content of this file, transpiled where needed and bundled together with +other JavaScript code it might need, will then be built using Webpack, resulting in file dist/bundle.js.

    + +

    We will see what that means and how it works in a moment. Now, however, we need to get back to our server code and teach +it to serve not only file index.html, but also file dist/bundle.js when it is asked for +http://127.0.0.1:8080/bundle.js:

    + +
    import http from 'http';
    +import fs from 'fs';
    +import path from 'path';
    +
    +const indexHtmlContent = fs.readFileSync(path.join(__dirname, '/../../dist/index.html'));
    +
    +http.createServer((req, res) => {
    +  if (req.url === '/') {
    +    res.writeHead(200, { 'Content-Type': 'text/html' });
    +    res.end(indexHtmlContent);
    +  } else if (req.url === '/bundle.js') {
    +    const bundleJsContent = fs.readFileSync(path.join(__dirname, '/../../dist/bundle.js'));
    +    res.writeHead(200, { 'Content-Type': 'application/javascript' });
    +    res.end(bundleJsContent);
    +  } else {
    +    res.writeHead(404, { 'Content-Type': 'text/plain' });
    +    res.end('Not found');
    +  }
    +}).listen(8080);
    +
    +console.log('Server running at http://127.0.0.1:8080/');
    +
    + +

    Because we expect file dist/bundle.js to change regularly, we read it anew from disk every time it is requested - this +way, we don’t need to restart our Node.js server everytime the file changes.

    + +

    Do not (re)start the server just yet, though - file dist/bundle.js still doesn’t exist, and because we have not added +any error handling to our server as this is just a demo, it would completely crash with +Error: ENOENT: no such file or directory as soon as we request the webpage.

    + +

    Next, we create our own frontend code. In file src/frontend/index.js, we write a very minimalistic application that +simply replaces the text in our content div with “Hello, World!”, using jQuery:

    + +
    import $ from 'jquery';
    +
    +$('#content').html('Hello, World!');
    +
    + +

    Let’s find out what we need to get that working.

    + +

    First of all, we use jQuery, which means we need to pull that in. Instead of requesting it from a CDN or manually +downloading it into our dist folder, we do something counter-intuitive. We install it via NPM:

    + +
    npm install --save jquery
    +
    + +

    This pulls in the latest version of jQuery into our node_modules folder. As you can see in our index.js code, we use +the ES6 import module loader to make jQuery available under identifier $ in our application. But how can we load +jQuery into the browser without a <script src="..."> tag in our index.html file, and how can we resolve the import +statement although browsers do not yet support ES6 JavaScript?

    + +

    Again, we need Babel, but now we also need Webpack.

    + +

    Webpack describes itself as “a bundler for javascript and friends”. The reason it exists is that the way we want to +organize our own code and its external dependencies, and the way that JavaScript and other assets are best served to a +browser, are often very different, and this difference can be cumbersome to manage.

    + +

    Webpack makes this a lot easier: we organize and write our own code the way we want, we refer to external dependencies +like the NPM-installed jQuery library the way we want, and we have Webpack bundle it all together in one single +bundle.js file which has all the content the browser needs, served in the format it likes. Because Webpack integrates +with Babel, the bundled file is guaranteed to only contain browser-friendly ES5 code.

    + +

    The price we pay for this is some setup work that we need to do, but which isn’t that complicated.

    + +

    We start by installing Webpack and a plugin it needs to work together with Babel:

    + +
    npm install webpack babel-loader --save-dev
    +
    + +

    Then, we put the following configuration in file webpack.config.js in the es6-demo root folder:

    + +
    const path = require('path');
    +
    +module.exports = {
    +  entry: {
    +    app: path.resolve(__dirname, 'src/frontend/index.js'),
    +  },
    +  module: {
    +    loaders: [
    +      {
    +        loader: "babel-loader",
    +        
    +        // Skip any files outside of your project's `src/frontend` directory
    +        include: [
    +          path.resolve(__dirname, 'src/frontend'),
    +        ],
    +        
    +        // Only run `.js` files through Babel
    +        test: /\.js?$/,
    +      },
    +    ],
    +  },
    +  output: {
    +    filename: 'bundle.js',
    +    path: path.resolve(__dirname, 'dist'),
    +  },
    +};
    +
    + +

    This tells Webpack several things:

    + +
      +
    • the entry file of our frontend application is src/frontend/index.js
    • +
    • we want to use the loader babel-loader
    • +
    • this loader shall only transpile files in src/frontend - with jQuery, we are only using libraries in node_modules +which are already ES5, so we don’t need to transpile these
    • +
    • we also want Babel to ignore any files that don’t end in .js
    • +
    • last but not least, we want Webpack to generate the final result into file bundle.js in folder dist
    • +
    + +

    With this, we are all set to experience our final application.

    + +

    First, (re)start the backend server in one terminal session:

    + +
    ./node_modules/.bin/babel-node src/backend/server.js
    +
    + +

    Next, in another terminal session, have Webpack build our frontend application bundle:

    + +
    ./node_modules/.bin/webpack
    +
    + +

    Finally, open a browser window at http://127.0.0.1:8080/ and enjoy the beauty of your first back-to-front ES6 +application - that is, you should see a very spartan page that greets you with Hello, World!.

    + +

    Let’s dissect what exactly happens.

    + +

    As before, opening the page in your browser sends a request to the running Node.js backend server. The server code +(which has been transpiled on-the-fly from ES6 to ES5 via babel-node) receives the request for URL /, and responds +with the content of file dist/index.html.

    + +

    This HTML file is rendered by the browser. The browser encounters the <script src="bundle.js"></script> line, and as +a result, it sends another request to http://127.0.0.1:8080/bundle.js.

    + +

    Again, our server receives that request, and responds with the contents of file dist/bundle.js. This file has been +generated by Webpack.

    + +

    Running ./node_modules/.bin/webpack made Webpack look at our main frontend code file in +src/frontend/index.js, which it knows about because it is defined as the application entry point in +webpack.config.js.

    + +

    Because Webpack is configured to run all .js files in folder src/frontend through its babel-loader, our code is +interpreted and transpiled via Babel. While doing so, Webpack recognizes that our code imports a library named +jquery. In order to make the code of this library available to our own code, Webpack pulls in the contents of file +node_modules/jquery/dist/jquery.js and adds it to file dist/bundle.js. Our own code is bundled into the file, too.

    + +

    Finally, our browser receives the response from our server containing the contents of file bundle.js, and runs +the contained JavaScript code, resulting in the Hello, World! page.

    + +
    + +
    +

    Learn more about writing web applications using Node.js +with The Node Beginner Book - the first part of this step-by-step Node.js tutorial +is available for free!

    +
    +
    +
    + +
    +
    + + + +
    + + + + + + + diff --git a/blog/sitemap.xml b/blog/sitemap.xml index bebf692..59a315b 100644 --- a/blog/sitemap.xml +++ b/blog/sitemap.xml @@ -1,5 +1,26 @@ - + + + + https://www.nodebeginner.org/blog/post/setting-up-a-javascript-project-for-es6-development-with-babel-and-webpack/ + 2017-10-08T09:18:00+02:00 + + + + https://www.nodebeginner.org/blog/post/javascript-news-and-resources-october-2017/ + 2017-10-07T17:34:00+02:00 + + + + https://www.nodebeginner.org/blog/post/nodejs-tutorial-how-to-work-with-websockets/ + 2017-09-18T18:21:17+02:00 + + + + https://www.nodebeginner.org/blog/post/nodejs-tutorial-what-are-node.js-modules/ + 2017-07-05T21:52:56+02:00 + https://www.nodebeginner.org/blog/post/nodejs-tutorial-optimizing-code-performance-using-async/ @@ -23,7 +44,7 @@ https://www.nodebeginner.org/blog/post/ - 2017-06-06T08:22:42+02:00 + 2017-10-08T09:18:00+02:00 0 @@ -34,7 +55,7 @@ https://www.nodebeginner.org/blog/ - 2017-06-06T08:22:42+02:00 + 2017-10-08T09:18:00+02:00 0 diff --git a/book.html b/book.html index 8dce54c..7e7ce08 100644 --- a/book.html +++ b/book.html @@ -10,7 +10,7 @@ - + Redirecting to The Node Beginner Book... diff --git a/buy-bundle-bottom/index.html b/buy-bundle-bottom/index.html index e49fdcb..3070217 100644 --- a/buy-bundle-bottom/index.html +++ b/buy-bundle-bottom/index.html @@ -10,7 +10,7 @@ - + You are being redirected to the Node.js Bundle page... diff --git a/buy-bundle-bottom/php.ini b/buy-bundle-bottom/php.ini index 1563ee2..d81a4c5 100644 --- a/buy-bundle-bottom/php.ini +++ b/buy-bundle-bottom/php.ini @@ -1,4 +1,4 @@ short_open_tag=off output_handler=ob_gzhandler -auto_prepend_file=/kunden/homepages/0/d271931425/htdocs/www.nodebeginner.org/header.php -auto_append_file=/kunden/homepages/0/d271931425/htdocs/www.nodebeginner.org/footer.php +auto_prepend_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/header.php +auto_append_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/footer.php diff --git a/buy-bundle/index.html b/buy-bundle/index.html index 9dca3ca..027b022 100644 --- a/buy-bundle/index.html +++ b/buy-bundle/index.html @@ -10,7 +10,7 @@ - + You are being redirected to the Node.js Bundle page... diff --git a/buy-bundle/oldindex.html b/buy-bundle/oldindex.html index 485b6f9..e2bf493 100644 --- a/buy-bundle/oldindex.html +++ b/buy-bundle/oldindex.html @@ -10,7 +10,7 @@ - + You are being redirected to the Node.js Bundle page... diff --git a/buy-bundle/oldsalespitch.html b/buy-bundle/oldsalespitch.html index e49fdcb..3070217 100644 --- a/buy-bundle/oldsalespitch.html +++ b/buy-bundle/oldsalespitch.html @@ -10,7 +10,7 @@ - + You are being redirected to the Node.js Bundle page... diff --git a/buy-bundle/php.ini b/buy-bundle/php.ini index 1563ee2..d81a4c5 100644 --- a/buy-bundle/php.ini +++ b/buy-bundle/php.ini @@ -1,4 +1,4 @@ short_open_tag=off output_handler=ob_gzhandler -auto_prepend_file=/kunden/homepages/0/d271931425/htdocs/www.nodebeginner.org/header.php -auto_append_file=/kunden/homepages/0/d271931425/htdocs/www.nodebeginner.org/footer.php +auto_prepend_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/header.php +auto_append_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/footer.php diff --git a/buy-bundle/salespitch.html b/buy-bundle/salespitch.html index e49fdcb..3070217 100644 --- a/buy-bundle/salespitch.html +++ b/buy-bundle/salespitch.html @@ -10,7 +10,7 @@ - + You are being redirected to the Node.js Bundle page... diff --git a/buy-chinese/index.html b/buy-chinese/index.html index c40f714..5e0672a 100644 --- a/buy-chinese/index.html +++ b/buy-chinese/index.html @@ -10,7 +10,7 @@ - + 正在前往电子书购买页面…… diff --git a/buy-ibook/index.html b/buy-ibook/index.html index e49fdcb..3070217 100644 --- a/buy-ibook/index.html +++ b/buy-ibook/index.html @@ -10,7 +10,7 @@ - + You are being redirected to the Node.js Bundle page... diff --git a/buy-kindle/index.html b/buy-kindle/index.html index b4c7bff..9e95cbf 100644 --- a/buy-kindle/index.html +++ b/buy-kindle/index.html @@ -10,7 +10,7 @@ - + You are being redirected to the Node.js Bundle page... diff --git a/buy-kindle/reviews.html b/buy-kindle/reviews.html index b4c7bff..9e95cbf 100644 --- a/buy-kindle/reviews.html +++ b/buy-kindle/reviews.html @@ -10,7 +10,7 @@ - + You are being redirected to the Node.js Bundle page... diff --git a/buy/index.html b/buy/index.html index b5ca57d..457b99a 100644 --- a/buy/index.html +++ b/buy/index.html @@ -10,7 +10,7 @@ - + You are being redirected to the product page of The Node Beginner Book... diff --git a/default_index.css b/default_index.css new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/default_index.css @@ -0,0 +1 @@ + diff --git a/header.php b/header.php index 739946f..ad258ac 100644 --- a/header.php +++ b/header.php @@ -18,6 +18,25 @@ die(); } +if ( $_SERVER['REQUEST_URI'] === '/blog/post/' + || $_SERVER['REQUEST_URI'] === '/blog/post' + || $_SERVER['REQUEST_URI'] === '/blog/post/index.html') +{ + header('HTTP/1.1 301 Moved Permanently'); + header('Location: https://www.nodebeginner.org/blog/'); + die(); +} + +if ( $_SERVER['REQUEST_URI'] === '/web-development-beginner-tutorial/post/' + || $_SERVER['REQUEST_URI'] === '/web-development-beginner-tutorial/post' + || $_SERVER['REQUEST_URI'] === '/web-development-beginner-tutorial/post/index.html') +{ + header('HTTP/1.1 301 Moved Permanently'); + header('Location: https://www.nodebeginner.org/web-development-beginner-tutorial/'); + die(); +} + + ob_start(); $httpHost = $_SERVER['HTTP_HOST']; @@ -28,7 +47,7 @@ $extension = $pathinfo['extension']; if ($extension != 'html') { - header('Cache-Control: max-age=604800'); // 1 week + header('Expires: ' . gmdate('D, d M Y H:i:s T', time() + 604800)); // 1 week } if ($extension == 'html') { @@ -54,3 +73,6 @@ if ($extension == 'gif') { header('Content-type: image/gif'); } + + +header('X-Went-Through-Header-File: yes'); diff --git a/hipsters.html b/hipsters.html index 8dce54c..7e7ce08 100644 --- a/hipsters.html +++ b/hipsters.html @@ -10,7 +10,7 @@ - + Redirecting to The Node Beginner Book... diff --git a/home/index.html b/home/index.html index 1d5390d..51b283b 100644 --- a/home/index.html +++ b/home/index.html @@ -10,7 +10,7 @@ - + Redirecting to The Node Beginner Book... diff --git a/hyperdev.html b/hyperdev.html index 8dce54c..7e7ce08 100644 --- a/hyperdev.html +++ b/hyperdev.html @@ -10,7 +10,7 @@ - + Redirecting to The Node Beginner Book... diff --git a/imprint.html b/imprint.html index e01642f..0fce39a 100644 --- a/imprint.html +++ b/imprint.html @@ -11,12 +11,12 @@
     Diese Webseite wird betrieben von:
     
    -Manuel Kiessling
    -Freiherrenstr. 32
    +Manuel Kießling
    +Berger Busch 55
     41515 Grevenbroich
     Deutschland
     
    -Telefon: 0049-160-96990445
    +Telefon: 0049-2181-7838778
     E-Mail: manuel@kiessling.net
     Internet: http://manuel.kiessling.net
     
    @@ -24,12 +24,12 @@
     
     Koordination dieses Auftritts, Redaktion und Verantwortung für die Inhalte übernimmt nach § 5 Telemediengesetz (TMG):
     
    -Manuel Kiessling
    -Freiherrenstr. 32
    +Manuel Kießling
    +Berger Busch 55
     41515 Grevenbroich
     Deutschland
     
    -Telefon: 0049-160-96990445
    +Telefon: 0049-2181-7838778
     E-Mail: manuel@kiessling.net
     Internet: http://manuel.kiessling.net
     
    @@ -64,39 +64,229 @@
     Sollten Sie trotzdem auf eine Urheberrechtsverletzung aufmerksam werden, bitten wir um einen entsprechenden Hinweis. Bei
     Bekanntwerden von Rechtsverletzungen werden wir derartige Inhalte umgehend entfernen.
     
    -Datenschutz
    -
    -Die Nutzung unserer Webseite ist in der Regel ohne Angabe personenbezogener Daten möglich. Soweit auf unseren Seiten
    -personenbezogene Daten (beispielsweise Name, Anschrift oder E-Mail Adressen) erhoben werden, erfolgt dies, soweit
    -möglich, stets auf freiwilliger Basis. Diese Daten werden ohne Ihre ausdrückliche Zustimmung nicht an Dritte
    -weitergegeben.
    -Wir weisen darauf hin, dass die Datenübertragung im Internet (z.B. bei der Kommunikation per E-Mail) Sicherheitslücken
    -aufweisen kann. Ein lückenloser Schutz der Daten vor dem Zugriff durch Dritte ist nicht möglich.
    -Der Nutzung von im Rahmen der Impressumspflicht veröffentlichten Kontaktdaten durch Dritte zur Übersendung von nicht
    -ausdrücklich angeforderter Werbung und Informationsmaterialien wird hiermit ausdrücklich widersprochen. Die Betreiber
    -der Seiten behalten sich ausdrücklich rechtliche Schritte im Falle der unverlangten Zusendung von Werbeinformationen,
    -etwa durch Spam-Mails, vor.
    -
    -Google Analytics
    -
    -Diese Website benutzt Google Analytics, einen Webanalysedienst der Google Inc. (“Google”). Google Analytics verwendet
    -sog. “Cookies”, Textdateien, die auf Ihrem Computer gespeichert werden und die eine Analyse der Benutzung der Website
    -durch Sie ermöglicht. Die durch den Cookie erzeugten Informationen über Ihre Benutzung diese Website (einschließlich
    -Ihrer IP-Adresse) wird an einen Server von Google in den USA übertragen und dort gespeichert. Google wird diese
    -Informationen benutzen, um Ihre Nutzung der Website auszuwerten, um Reports über die Websiteaktivitäten für die
    -Websitebetreiber zusammenzustellen und um weitere mit der Websitenutzung und der Internetnutzung verbundene
    -Dienstleistungen zu erbringen. Auch wird Google diese Informationen gegebenenfalls an Dritte übertragen, sofern dies
    -gesetzlich vorgeschrieben oder soweit Dritte diese Daten im Auftrag von Google verarbeiten. Google wird in keinem Fall
    -Ihre IP-Adresse mit anderen Daten der Google in Verbindung bringen. Sie können die Installation der Cookies durch eine
    -entsprechende Einstellung Ihrer Browser Software verhindern; wir weisen Sie jedoch darauf hin, dass Sie in diesem Fall
    -gegebenenfalls nicht sämtliche Funktionen dieser Website voll umfänglich nutzen können. Durch die Nutzung dieser Website
    -erklären Sie sich mit der Bearbeitung der über Sie erhobenen Daten durch Google in der zuvor beschriebenen Art und Weise
    -und zu dem zuvor benannten Zweck einverstanden.
    -
    -
     Website Impressum erstellt durch impressum-generator.de von der Kanzlei Hasselbach, Frankfurt
     
    +

    Datenschutzerklärung

    +

    +

    Diese Datenschutzerklärung klärt Sie über die Art, den Umfang und Zweck der Verarbeitung von personenbezogenen Daten + (nachfolgend kurz „Daten“) innerhalb unseres Onlineangebotes und der mit ihm verbundenen Webseiten, Funktionen und + Inhalte sowie externen Onlinepräsenzen, wie z.B. unser Social Media Profile auf (nachfolgend gemeinsam bezeichnet + als „Onlineangebot“). Im Hinblick auf die verwendeten Begrifflichkeiten, wie z.B. „Verarbeitung“ oder + „Verantwortlicher“ verweisen wir auf die Definitionen im Art. 4 der Datenschutzgrundverordnung (DSGVO).
    +
    +

    +

    Verantwortlicher

    +

    Manuel Kießling
    +Berger Busch 55
    +41515 Grevenbroich
    +Deutschland
    +
    +E-Mailadresse: manuel@kiessling.net
    +Link zum Impressum: http://manuel.kiessling.net/imprint-impressum-datenschutz-haftung
    +

    +

    Arten der verarbeiteten Daten:

    +

    - Bestandsdaten (z.B., Namen, Adressen).
    + - Kontaktdaten (z.B., E-Mail, Telefonnummern).
    + - Inhaltsdaten (z.B., Texteingaben, Fotografien, Videos).
    + - Nutzungsdaten (z.B., besuchte Webseiten, Interesse an Inhalten, Zugriffszeiten).
    + - Meta-/Kommunikationsdaten (z.B., Geräte-Informationen, IP-Adressen).
    +

    +

    Kategorien betroffener Personen

    +

    Besucher und Nutzer des Onlineangebotes (Nachfolgend bezeichnen wir die betroffenen Personen zusammenfassend auch als + „Nutzer“).
    +

    +

    Zweck der Verarbeitung

    +

    - Zurverfügungstellung des Onlineangebotes, seiner Funktionen und Inhalte.
    + - Beantwortung von Kontaktanfragen und Kommunikation mit Nutzern.
    + - Sicherheitsmaßnahmen.
    + - Reichweitenmessung/Marketing
    +

    +

    Verwendete Begrifflichkeiten

    +

    „Personenbezogene Daten“ sind alle Informationen, die sich auf eine identifizierte oder identifizierbare natürliche + Person (im Folgenden „betroffene Person“) beziehen; als identifizierbar wird eine natürliche Person angesehen, die + direkt oder indirekt, insbesondere mittels Zuordnung zu einer Kennung wie einem Namen, zu einer Kennnummer, zu + Standortdaten, zu einer Online-Kennung (z.B. Cookie) oder zu einem oder mehreren besonderen Merkmalen identifiziert + werden kann, die Ausdruck der physischen, physiologischen, genetischen, psychischen, wirtschaftlichen, kulturellen + oder sozialen Identität dieser natürlichen Person sind.
    +
    + „Verarbeitung“ ist jeder mit oder ohne Hilfe automatisierter Verfahren ausgeführte Vorgang oder jede solche + Vorgangsreihe im Zusammenhang mit personenbezogenen Daten. Der Begriff reicht weit und umfasst praktisch jeden + Umgang mit Daten.
    +
    + „Pseudonymisierung“ die Verarbeitung personenbezogener Daten in einer Weise, dass die personenbezogenen Daten ohne + Hinzuziehung zusätzlicher Informationen nicht mehr einer spezifischen betroffenen Person zugeordnet werden können, + sofern diese zusätzlichen Informationen gesondert aufbewahrt werden und technischen und organisatorischen Maßnahmen + unterliegen, die gewährleisten, dass die personenbezogenen Daten nicht einer identifizierten oder identifizierbaren + natürlichen Person zugewiesen werden.
    +
    + „Profiling“ jede Art der automatisierten Verarbeitung personenbezogener Daten, die darin besteht, dass diese + personenbezogenen Daten verwendet werden, um bestimmte persönliche Aspekte, die sich auf eine natürliche Person + beziehen, zu bewerten, insbesondere um Aspekte bezüglich Arbeitsleistung, wirtschaftliche Lage, Gesundheit, + persönliche Vorlieben, Interessen, Zuverlässigkeit, Verhalten, Aufenthaltsort oder Ortswechsel dieser natürlichen + Person zu analysieren oder vorherzusagen.
    +
    + Als „Verantwortlicher“ wird die natürliche oder juristische Person, Behörde, Einrichtung oder andere Stelle, die + allein oder gemeinsam mit anderen über die Zwecke und Mittel der Verarbeitung von personenbezogenen Daten + entscheidet, bezeichnet.
    +
    + „Auftragsverarbeiter“ eine natürliche oder juristische Person, Behörde, Einrichtung oder andere Stelle, die + personenbezogene Daten im Auftrag des Verantwortlichen verarbeitet.
    +

    +

    Maßgebliche Rechtsgrundlagen

    +

    Nach Maßgabe des Art. 13 DSGVO teilen wir Ihnen die Rechtsgrundlagen unserer Datenverarbeitungen mit. Sofern die + Rechtsgrundlage in der Datenschutzerklärung nicht genannt wird, gilt Folgendes: Die Rechtsgrundlage für die + Einholung von Einwilligungen ist Art. 6 Abs. 1 lit. a und Art. 7 DSGVO, die Rechtsgrundlage für die Verarbeitung zur + Erfüllung unserer Leistungen und Durchführung vertraglicher Maßnahmen sowie Beantwortung von Anfragen ist Art. 6 + Abs. 1 lit. b DSGVO, die Rechtsgrundlage für die Verarbeitung zur Erfüllung unserer rechtlichen Verpflichtungen ist + Art. 6 Abs. 1 lit. c DSGVO, und die Rechtsgrundlage für die Verarbeitung zur Wahrung unserer berechtigten Interessen + ist Art. 6 Abs. 1 lit. f DSGVO. Für den Fall, dass lebenswichtige Interessen der betroffenen Person oder einer + anderen natürlichen Person eine Verarbeitung personenbezogener Daten erforderlich machen, dient Art. 6 Abs. 1 lit. d + DSGVO als Rechtsgrundlage.

    +

    Sicherheitsmaßnahmen

    +

    Wir treffen nach Maßgabe des Art. 32 DSGVO unter Berücksichtigung des Stands der Technik, der Implementierungskosten + und der Art, des Umfangs, der Umstände und der Zwecke der Verarbeitung sowie der unterschiedlichen + Eintrittswahrscheinlichkeit und Schwere des Risikos für die Rechte und Freiheiten natürlicher Personen, geeignete + technische und organisatorische Maßnahmen, um ein dem Risiko angemessenes Schutzniveau zu gewährleisten.
    +
    + Zu den Maßnahmen gehören insbesondere die Sicherung der Vertraulichkeit, Integrität und Verfügbarkeit von Daten + durch Kontrolle des physischen Zugangs zu den Daten, als auch des sie betreffenden Zugriffs, der Eingabe, + Weitergabe, der Sicherung der Verfügbarkeit und ihrer Trennung. Des Weiteren haben wir Verfahren eingerichtet, die + eine Wahrnehmung von Betroffenenrechten, Löschung von Daten und Reaktion auf Gefährdung der Daten gewährleisten. + Ferner berücksichtigen wir den Schutz personenbezogener Daten bereits bei der Entwicklung, bzw. Auswahl von + Hardware, Software sowie Verfahren, entsprechend dem Prinzip des Datenschutzes durch Technikgestaltung und durch + datenschutzfreundliche Voreinstellungen (Art. 25 DSGVO).
    +

    +

    Zusammenarbeit mit Auftragsverarbeitern und Dritten

    +

    Sofern wir im Rahmen unserer Verarbeitung Daten gegenüber anderen Personen und Unternehmen (Auftragsverarbeitern oder + Dritten) offenbaren, sie an diese übermitteln oder ihnen sonst Zugriff auf die Daten gewähren, erfolgt dies nur auf + Grundlage einer gesetzlichen Erlaubnis (z.B. wenn eine Übermittlung der Daten an Dritte, wie an + Zahlungsdienstleister, gem. Art. 6 Abs. 1 lit. b DSGVO zur Vertragserfüllung erforderlich ist), Sie eingewilligt + haben, eine rechtliche Verpflichtung dies vorsieht oder auf Grundlage unserer berechtigten Interessen (z.B. beim + Einsatz von Beauftragten, Webhostern, etc.).
    +
    + Sofern wir Dritte mit der Verarbeitung von Daten auf Grundlage eines sog. „Auftragsverarbeitungsvertrages“ + beauftragen, geschieht dies auf Grundlage des Art. 28 DSGVO.

    +

    Übermittlungen in Drittländer

    +

    Sofern wir Daten in einem Drittland (d.h. außerhalb der Europäischen Union (EU) oder des Europäischen + Wirtschaftsraums (EWR)) verarbeiten oder dies im Rahmen der Inanspruchnahme von Diensten Dritter oder Offenlegung, + bzw. Übermittlung von Daten an Dritte geschieht, erfolgt dies nur, wenn es zur Erfüllung unserer (vor)vertraglichen + Pflichten, auf Grundlage Ihrer Einwilligung, aufgrund einer rechtlichen Verpflichtung oder auf Grundlage unserer + berechtigten Interessen geschieht. Vorbehaltlich gesetzlicher oder vertraglicher Erlaubnisse, verarbeiten oder + lassen wir die Daten in einem Drittland nur beim Vorliegen der besonderen Voraussetzungen der Art. 44 ff. DSGVO + verarbeiten. D.h. die Verarbeitung erfolgt z.B. auf Grundlage besonderer Garantien, wie der offiziell anerkannten + Feststellung eines der EU entsprechenden Datenschutzniveaus (z.B. für die USA durch das „Privacy Shield“) oder + Beachtung offiziell anerkannter spezieller vertraglicher Verpflichtungen (so genannte + „Standardvertragsklauseln“).

    +

    Rechte der betroffenen Personen

    +

    Sie haben das Recht, eine Bestätigung darüber zu verlangen, ob betreffende Daten verarbeitet werden und auf Auskunft + über diese Daten sowie auf weitere Informationen und Kopie der Daten entsprechend Art. 15 DSGVO.
    +
    + Sie haben entsprechend. Art. 16 DSGVO das Recht, die Vervollständigung der Sie betreffenden Daten oder die + Berichtigung der Sie betreffenden unrichtigen Daten zu verlangen.
    +
    + Sie haben nach Maßgabe des Art. 17 DSGVO das Recht zu verlangen, dass betreffende Daten unverzüglich gelöscht + werden, bzw. alternativ nach Maßgabe des Art. 18 DSGVO eine Einschränkung der Verarbeitung der Daten zu + verlangen.
    +
    + Sie haben das Recht zu verlangen, dass die Sie betreffenden Daten, die Sie uns bereitgestellt haben nach Maßgabe des + Art. 20 DSGVO zu erhalten und deren Übermittlung an andere Verantwortliche zu fordern.
    +
    + Sie haben ferner gem. Art. 77 DSGVO das Recht, eine Beschwerde bei der zuständigen Aufsichtsbehörde einzureichen. +

    +

    Widerrufsrecht

    +

    Sie haben das Recht, erteilte Einwilligungen gem. Art. 7 Abs. 3 DSGVO mit Wirkung für die Zukunft zu widerrufen

    +

    Widerspruchsrecht

    +

    Sie können der künftigen Verarbeitung der Sie betreffenden Daten nach Maßgabe des Art. 21 DSGVO jederzeit + widersprechen. Der Widerspruch kann insbesondere gegen die Verarbeitung für Zwecke der Direktwerbung erfolgen.

    +

    Cookies und Widerspruchsrecht bei Direktwerbung

    +

    Als „Cookies“ werden kleine Dateien bezeichnet, die auf Rechnern der Nutzer gespeichert werden. Innerhalb der Cookies + können unterschiedliche Angaben gespeichert werden. Ein Cookie dient primär dazu, die Angaben zu einem Nutzer (bzw. + dem Gerät auf dem das Cookie gespeichert ist) während oder auch nach seinem Besuch innerhalb eines Onlineangebotes + zu speichern. Als temporäre Cookies, bzw. „Session-Cookies“ oder „transiente Cookies“, werden Cookies bezeichnet, + die gelöscht werden, nachdem ein Nutzer ein Onlineangebot verlässt und seinen Browser schließt. In einem solchen + Cookie kann z.B. der Inhalt eines Warenkorbs in einem Onlineshop oder ein Login-Status gespeichert werden. Als + „permanent“ oder „persistent“ werden Cookies bezeichnet, die auch nach dem Schließen des Browsers gespeichert + bleiben. So kann z.B. der Login-Status gespeichert werden, wenn die Nutzer diese nach mehreren Tagen aufsuchen. + Ebenso können in einem solchen Cookie die Interessen der Nutzer gespeichert werden, die für Reichweitenmessung oder + Marketingzwecke verwendet werden. Als „Third-Party-Cookie“ werden Cookies bezeichnet, die von anderen Anbietern als + dem Verantwortlichen, der das Onlineangebot betreibt, angeboten werden (andernfalls, wenn es nur dessen Cookies sind + spricht man von „First-Party Cookies“).
    +
    + Wir können temporäre und permanente Cookies einsetzen und klären hierüber im Rahmen unserer Datenschutzerklärung + auf.
    +
    + Falls die Nutzer nicht möchten, dass Cookies auf ihrem Rechner gespeichert werden, werden sie gebeten die + entsprechende Option in den Systemeinstellungen ihres Browsers zu deaktivieren. Gespeicherte Cookies können in den + Systemeinstellungen des Browsers gelöscht werden. Der Ausschluss von Cookies kann zu Funktionseinschränkungen dieses + Onlineangebotes führen.
    +
    + Ein genereller Widerspruch gegen den Einsatz der zu Zwecken des Onlinemarketing eingesetzten Cookies kann bei einer + Vielzahl der Dienste, vor allem im Fall des Trackings, über die US-amerikanische Seite http://www.aboutads.info/choices/ oder die EU-Seite http://www.youronlinechoices.com/ erklärt werden. Des Weiteren + kann die Speicherung von Cookies mittels deren Abschaltung in den Einstellungen des Browsers erreicht werden. Bitte + beachten Sie, dass dann gegebenenfalls nicht alle Funktionen dieses Onlineangebotes genutzt werden können.

    +

    Löschung von Daten

    +

    Die von uns verarbeiteten Daten werden nach Maßgabe der Art. 17 und 18 DSGVO gelöscht oder in ihrer Verarbeitung + eingeschränkt. Sofern nicht im Rahmen dieser Datenschutzerklärung ausdrücklich angegeben, werden die bei uns + gespeicherten Daten gelöscht, sobald sie für ihre Zweckbestimmung nicht mehr erforderlich sind und der Löschung + keine gesetzlichen Aufbewahrungspflichten entgegenstehen. Sofern die Daten nicht gelöscht werden, weil sie für + andere und gesetzlich zulässige Zwecke erforderlich sind, wird deren Verarbeitung eingeschränkt. D.h. die Daten + werden gesperrt und nicht für andere Zwecke verarbeitet. Das gilt z.B. für Daten, die aus handels- oder + steuerrechtlichen Gründen aufbewahrt werden müssen.
    +
    + Nach gesetzlichen Vorgaben in Deutschland, erfolgt die Aufbewahrung insbesondere für 10 Jahre gemäß §§ 147 Abs. 1 + AO, 257 Abs. 1 Nr. 1 und 4, Abs. 4 HGB (Bücher, Aufzeichnungen, Lageberichte, Buchungsbelege, Handelsbücher, für + Besteuerung relevanter Unterlagen, etc.) und 6 Jahre gemäß § 257 Abs. 1 Nr. 2 und 3, Abs. 4 HGB (Handelsbriefe). +
    +
    + Nach gesetzlichen Vorgaben in Österreich erfolgt die Aufbewahrung insbesondere für 7 J gemäß § 132 Abs. 1 BAO + (Buchhaltungsunterlagen, Belege/Rechnungen, Konten, Belege, Geschäftspapiere, Aufstellung der Einnahmen und + Ausgaben, etc.), für 22 Jahre im Zusammenhang mit Grundstücken und für 10 Jahre bei Unterlagen im Zusammenhang mit + elektronisch erbrachten Leistungen, Telekommunikations-, Rundfunk- und Fernsehleistungen, die an Nichtunternehmer in + EU-Mitgliedstaaten erbracht werden und für die der Mini-One-Stop-Shop (MOSS) in Anspruch genommen wird.

    +

    +

    DISQUS-Kommentarfunktion

    +

    +

    Wir setzen auf Grundlage unserer berechtigten Interessen an einer effizienten, sicheren und nutzerfreundlichen Kommentarverwaltung gem. Art. 6 Abs. 1 lit. f. DSGVO den Kommentardienst DISQUS, angeboten von der DISQUS, Inc., 301 Howard St, Floor 3 San Francisco, California- 94105, USA, ein. DISQUS ist unter dem Privacy-Shield-Abkommen zertifiziert und bietet hierdurch eine Garantie, das europäische Datenschutzrecht einzuhalten: https://www.privacyshield.gov/participant?id=a2zt0000000TRkEAAW&status=Active.
    +
    +Zur Nutzung der DISQUS Kommentarfunktion können Nutzer sich über ein eigenes DISQUS-Nutzer-Konto oder einen bestehende Social-Media-Konten (z.B. OpenID, Facebook, Twitter oder Google) anmelden. Hierbei werden die Anmeldedaten der Nutzer durch DISQS von den Plattformen bezogen. Es ist ebenfalls möglich, die DISQUS-Kommentarfunktion als Gast, ohne Erstellung oder Verwendung Nutzerkontos bei DISQUS oder einem der angegebenen Social-Media-Anbieter, zu nutzen.
    +
    +Wir betten lediglich DISQUS mit seinen Funktionen in unsere Website ein, wobei wir auf die Kommentare der Nutzer Einfluss nehmen können. Die Nutzer treten jedoch in eine unmittelbare Vertragsbeziehung mit DISQUS, in deren Rahmen DISQS die Kommentare der Nutzer verarbeitet und ein Ansprechpartner für etwaige Löschung der Daten der Nutzer ist. Wir verweisen hierbei auf die Datenschutzerklärung von DISQUS: https://help.disqus.com/terms-and-policies/disqus-privacy-policy und weisen die Nutzer ebenfalls darauf hin, dass sie davon ausgehen können, dass DISQUS neben dem Kommentarinhalt auch deren IP-Adresse und den Zeitpunkt des Kommentars speichert sowie Cookies auf den Rechnern der Nutzer speichert und zur Darstellung von Werbung nutzen kann. Nutzer können jedoch der Verarbeitung ihrer Daten zwecks Darstellung von Anzeigen widersprechen: https://disqus.com/data-sharing-settings.
    +

    +

    +

    Abruf von Profilbildern bei Gravatar

    +

    +

    Wir setzen innerhalb unseres Onlineangebotes und insbesondere im Blog den Dienst Gravatar der Automattic Inc., 60 29th Street #343, San Francisco, CA 94110, USA, ein.
    +
    +Gravatar ist ein Dienst, bei dem sich Nutzer anmelden und Profilbilder und ihre E-Mailadressen hinterlegen können. Wenn Nutzer mit der jeweiligen E-Mailadresse auf anderen Onlinepräsenzen (vor allem in Blogs) Beiträge oder Kommentare hinterlassen, können so deren Profilbilder neben den Beiträgen oder Kommentaren dargestellt werden. Hierzu wird die von den Nutzern mitgeteilte E-Mailadresse an Gravatar zwecks Prüfung, ob zu ihr ein Profil gespeichert ist, verschlüsselt übermittelt. Dies ist der einzige Zweck der Übermittlung der E-Mailadresse und sie wird nicht für andere Zwecke verwendet, sondern danach gelöscht.
    +
    +Die Nutzung von Gravatar erfolgt auf Grundlage unserer berechtigten Interessen im Sinne des Art. 6 Abs. 1 lit. f) DSGVO, da wir mit Hilfe von Gravatar den Beitrags- und Kommentarverfassern die Möglichkeit bieten ihre Beiträge mit einem Profilbild zu personalisieren.
    +
    +Durch die Anzeige der Bilder bringt Gravatar die IP-Adresse der Nutzer in Erfahrung, da dies für eine Kommunikation zwischen einem Browser und einem Onlineservice notwendig ist. Nähere Informationen zur Erhebung und Nutzung der Daten durch Gravatar finden sich in den Datenschutzhinweisen von Automattic: https://automattic.com/privacy/.
    +
    +Wenn Nutzer nicht möchten, dass ein mit Ihrer E-Mail-Adresse bei Gravatar verknüpftes Benutzerbild in den Kommentaren erscheint, sollten Sie zum Kommentieren eine E-Mail-Adresse nutzen, welche nicht bei Gravatar hinterlegt ist. Wir weisen ferner darauf hin, dass es auch möglich ist eine anonyme oder gar keine E-Mailadresse zu verwenden, falls die Nutzer nicht wünschen, dass die eigene E-Mailadresse an Gravatar übersendet wird. Nutzer können die Übertragung der Daten komplett verhindern, indem Sie unser Kommentarsystem nicht nutzen.
    +

    +

    +

    Hosting

    +

    +

    Die von uns in Anspruch genommenen Hosting-Leistungen dienen der Zurverfügungstellung der folgenden Leistungen: Infrastruktur- und Plattformdienstleistungen, Rechenkapazität, Speicherplatz und Datenbankdienste, Sicherheitsleistungen sowie technische Wartungsleistungen, die wir zum Zwecke des Betriebs dieses Onlineangebotes einsetzen.
    +
    +Hierbei verarbeiten wir, bzw. unser Hostinganbieter Bestandsdaten, Kontaktdaten, Inhaltsdaten, Vertragsdaten, Nutzungsdaten, Meta- und Kommunikationsdaten von Kunden, Interessenten und Besuchern dieses Onlineangebotes auf Grundlage unserer berechtigten Interessen an einer effizienten und sicheren Zurverfügungstellung dieses Onlineangebotes gem. Art. 6 Abs. 1 lit. f DSGVO i.V.m. Art. 28 DSGVO (Abschluss Auftragsverarbeitungsvertrag).
    +

    +

    +

    Erhebung von Zugriffsdaten und Logfiles

    +

    +

    Wir, bzw. unser Hostinganbieter, erhebt auf Grundlage unserer berechtigten Interessen im Sinne des Art. 6 Abs. 1 lit. f. DSGVO Daten über jeden Zugriff auf den Server, auf dem sich dieser Dienst befindet (sogenannte Serverlogfiles). Zu den Zugriffsdaten gehören Name der abgerufenen Webseite, Datei, Datum und Uhrzeit des Abrufs, übertragene Datenmenge, Meldung über erfolgreichen Abruf, Browsertyp nebst Version, das Betriebssystem des Nutzers, Referrer URL (die zuvor besuchte Seite), IP-Adresse und der anfragende Provider.
    +
    +Logfile-Informationen werden aus Sicherheitsgründen (z.B. zur Aufklärung von Missbrauchs- oder Betrugshandlungen) für die Dauer von maximal 7 Tagen gespeichert und danach gelöscht. Daten, deren weitere Aufbewahrung zu Beweiszwecken erforderlich ist, sind bis zur endgültigen Klärung des jeweiligen Vorfalls von der Löschung ausgenommen.
    +

    +

    diff --git a/index-br.html b/index-br.html index 26b61f6..9063d74 100644 --- a/index-br.html +++ b/index-br.html @@ -12,7 +12,7 @@ - + Redirecting to https://leanpub.com/iniciante-node... diff --git a/index-en.html b/index-en.html index 4c47032..29f0426 100644 --- a/index-en.html +++ b/index-en.html @@ -13,7 +13,7 @@ - + diff --git a/index-es.html b/index-es.html index ac721f3..580979c 100644 --- a/index-es.html +++ b/index-es.html @@ -17,7 +17,7 @@ - + @@ -2241,20 +2241,16 @@

    Manejando Peticiones POST

    diff --git a/index-jp.html b/index-jp.html index c0ae742..81aa1e9 100644 --- a/index-jp.html +++ b/index-jp.html @@ -21,8 +21,8 @@ - + @@ -1327,7 +1327,7 @@

    リクエストを”ルーティング”するために必要なものは また出てきました。関数を渡していますね。これはもう目新しいことではないはずです。

    -

    ここで(node indes.jsとして)アプリケーションを起動してURLへリクエストを送ったら、 +

    ここで(node index.jsとして)アプリケーションを起動してURLへリクエストを送ったら、 HTTPサーバがルータを使用している様子、それからリクエストされたパス名が渡されている様子が、 アプリケーションの出力内容からわかるはずです:

    @@ -3438,19 +3438,16 @@

    まとめと展望

    diff --git a/index-kr.html b/index-kr.html index 79cd1d7..e24b128 100644 --- a/index-kr.html +++ b/index-kr.html @@ -15,7 +15,7 @@ - + @@ -3547,20 +3547,16 @@

    결론과 개관

    diff --git a/index-ru.html b/index-ru.html index 036a197..7daafd6 100644 --- a/index-ru.html +++ b/index-ru.html @@ -12,7 +12,7 @@ - + Redirecting to http://www.nodebeginner.ru/... diff --git a/index-vi.html b/index-vi.html index 8890bbe..f12b803 100644 --- a/index-vi.html +++ b/index-vi.html @@ -13,7 +13,7 @@ - +
    @@ -1276,20 +1276,16 @@

    Sự điều hướng request tới request handlers

    @@ -1297,8 +1293,8 @@

    Sự điều hướng request tới request handlers

    - + @@ -2679,20 +2679,16 @@

    总结与展望

    diff --git a/index-zh-tw.html b/index-zh-tw.html index 8aa57c0..dc16af6 100644 --- a/index-zh-tw.html +++ b/index-zh-tw.html @@ -22,7 +22,7 @@ // Disqus var disqus_shortname = 'nodebeginner'; var disqus_identifier = 'nodebeginner-book-chinese'; - var disqus_url = 'https://www.nodebeginner.org/index-zh-cn.html'; + var disqus_url = 'https://www.nodebeginner.org/index-zh-tw.html'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js'; @@ -30,7 +30,7 @@ })(); - + @@ -2681,20 +2681,16 @@

    總結與展望

    diff --git a/index.html b/index.html index 7eb4faa..6eb6637 100644 --- a/index.html +++ b/index.html @@ -1,1288 +1,1974 @@ - - - - - - The Node Beginner Book » A comprehensive Node.js tutorial - - - - - - - - - - - - - + diff --git a/index.old.html b/index.old.html index 8dce54c..7e7ce08 100644 --- a/index.old.html +++ b/index.old.html @@ -10,7 +10,7 @@ - + Redirecting to The Node Beginner Book... diff --git a/index2.html b/index2.html index 8dce54c..7e7ce08 100644 --- a/index2.html +++ b/index2.html @@ -10,7 +10,7 @@ - + Redirecting to The Node Beginner Book... diff --git a/manuelkiessling.jpg b/manuelkiessling.jpg index e55c093..6c47a51 100644 Binary files a/manuelkiessling.jpg and b/manuelkiessling.jpg differ diff --git a/nodebeginner_org-opengraph-image.png b/nodebeginner_org-opengraph-image.png new file mode 100644 index 0000000..c3bf917 Binary files /dev/null and b/nodebeginner_org-opengraph-image.png differ diff --git a/php.ini b/php.ini index 1563ee2..3c452e2 100644 --- a/php.ini +++ b/php.ini @@ -1,4 +1,5 @@ short_open_tag=off -output_handler=ob_gzhandler -auto_prepend_file=/kunden/homepages/0/d271931425/htdocs/www.nodebeginner.org/header.php -auto_append_file=/kunden/homepages/0/d271931425/htdocs/www.nodebeginner.org/footer.php +zlib.output_compression=1 +zlib.output_compression_level=9 +auto_prepend_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/header.php +auto_append_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/footer.php diff --git a/robots.txt b/robots.txt index d9ad343..db0ef7f 100644 --- a/robots.txt +++ b/robots.txt @@ -1,5 +1,11 @@ User-agent: * -Disallow: +Disallow: /blog/categories/ +Disallow: /blog/tags/ +Disallow: /blog/page/ +Disallow: /web-development-beginner-tutorial/categories/ +Disallow: /web-development-beginner-tutorial/tags/ +Disallow: /web-development-beginner-tutorial/page/ +Sitemap: https://www.nodebeginner.org/sitemap.xml Sitemap: https://www.nodebeginner.org/blog/sitemap.xml Sitemap: https://www.nodebeginner.org/web-development-beginner-tutorial/sitemap.xml diff --git a/sitemap.xml b/sitemap.xml new file mode 100644 index 0000000..e42a043 --- /dev/null +++ b/sitemap.xml @@ -0,0 +1,52 @@ + + + + + https://www.nodebeginner.org/ + 2017-07-04T21:18:00+02:00 + 1.0 + + + + https://www.nodebeginner.org/index-br.html + 2017-06-23T11:16:00+02:00 + 0.5 + + + + https://www.nodebeginner.org/index-es.html + 2017-06-23T11:16:00+02:00 + 0.5 + + + + https://www.nodebeginner.org/index-jp.html + 2017-06-23T11:16:00+02:00 + 0.5 + + + + https://www.nodebeginner.org/index-kr.html + 2017-06-23T11:16:00+02:00 + 0.5 + + + + https://www.nodebeginner.org/index-vi.html + 2017-06-23T11:16:00+02:00 + 0.5 + + + + https://www.nodebeginner.org/index-zh-cn.html + 2017-06-23T11:16:00+02:00 + 0.5 + + + + https://www.nodebeginner.org/index-zh-tw.html + 2017-06-23T11:16:00+02:00 + 0.5 + + + diff --git a/superstack/1/index.html b/superstack/1/index.html new file mode 100644 index 0000000..7af852a --- /dev/null +++ b/superstack/1/index.html @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +You are being redirected to the Ultimate Programmer Super Stack page... + + diff --git a/superstack/index.html b/superstack/index.html new file mode 100644 index 0000000..eea5ae8 --- /dev/null +++ b/superstack/index.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + You are being redirected to the Ultimate Programmer Super Stack page... + + diff --git a/testimonial_benjamintodts.jpg b/testimonial_benjamintodts.jpg index 91e307b..26b1741 100644 Binary files a/testimonial_benjamintodts.jpg and b/testimonial_benjamintodts.jpg differ diff --git a/testimonial_erorus.png b/testimonial_erorus.png index efadac2..43641dc 100644 Binary files a/testimonial_erorus.png and b/testimonial_erorus.png differ diff --git a/testimonial_heidinewton.jpg b/testimonial_heidinewton.jpg index bca86b2..f55c9c5 100644 Binary files a/testimonial_heidinewton.jpg and b/testimonial_heidinewton.jpg differ diff --git a/testimonial_nickstrayer.jpg b/testimonial_nickstrayer.jpg index ba6ac35..d2b3917 100644 Binary files a/testimonial_nickstrayer.jpg and b/testimonial_nickstrayer.jpg differ diff --git a/the_node_craftsman_book_cover_small.png b/the_node_craftsman_book_cover_small.png index 3701ad2..6b64dfe 100644 Binary files a/the_node_craftsman_book_cover_small.png and b/the_node_craftsman_book_cover_small.png differ diff --git a/web-development-beginner-tutorial/.htaccess b/web-development-beginner-tutorial/.htaccess new file mode 100644 index 0000000..ce79fc2 --- /dev/null +++ b/web-development-beginner-tutorial/.htaccess @@ -0,0 +1 @@ +RemoveType .js .css .png .jpg .gif diff --git a/web-development-beginner-tutorial/index.html b/web-development-beginner-tutorial/index.html index 550a39b..9e45acf 100644 --- a/web-development-beginner-tutorial/index.html +++ b/web-development-beginner-tutorial/index.html @@ -2,7 +2,7 @@ - + The Web Development Beginner Tutorial @@ -10,7 +10,6 @@ - @@ -123,17 +122,6 @@

    - - diff --git a/web-development-beginner-tutorial/page/1/index.html b/web-development-beginner-tutorial/page/1/index.html index ac63403..ee41780 100644 --- a/web-development-beginner-tutorial/page/1/index.html +++ b/web-development-beginner-tutorial/page/1/index.html @@ -1 +1 @@ -https://www.nodebeginner.org/web-development-beginner-tutorial/ \ No newline at end of file +https://www.nodebeginner.org/web-development-beginner-tutorial/ \ No newline at end of file diff --git a/web-development-beginner-tutorial/php.ini b/web-development-beginner-tutorial/php.ini new file mode 100644 index 0000000..3c452e2 --- /dev/null +++ b/web-development-beginner-tutorial/php.ini @@ -0,0 +1,5 @@ +short_open_tag=off +zlib.output_compression=1 +zlib.output_compression_level=9 +auto_prepend_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/header.php +auto_append_file=/homepages/0/d271931425/htdocs/www.nodebeginner.org/footer.php diff --git a/web-development-beginner-tutorial/post/a-close-look-at-the-www/how-computer-programs-talk-to-each-other-over-the-internet/index.html b/web-development-beginner-tutorial/post/a-close-look-at-the-www/how-computer-programs-talk-to-each-other-over-the-internet/index.html index 3fdd038..2a60f35 100644 --- a/web-development-beginner-tutorial/post/a-close-look-at-the-www/how-computer-programs-talk-to-each-other-over-the-internet/index.html +++ b/web-development-beginner-tutorial/post/a-close-look-at-the-www/how-computer-programs-talk-to-each-other-over-the-internet/index.html @@ -9,7 +9,6 @@ - @@ -75,10 +74,18 @@

    @@ -99,16 +106,6 @@

    - @@ -179,16 +178,6 @@

    How web browsers an - diff --git a/web-development-beginner-tutorial/post/a-close-look-at-the-www/how-web-browsers-find-web-servers/index.html b/web-development-beginner-tutorial/post/a-close-look-at-the-www/how-web-browsers-find-web-servers/index.html index 9970580..adcabe2 100644 --- a/web-development-beginner-tutorial/post/a-close-look-at-the-www/how-web-browsers-find-web-servers/index.html +++ b/web-development-beginner-tutorial/post/a-close-look-at-the-www/how-web-browsers-find-web-servers/index.html @@ -9,7 +9,6 @@ - @@ -266,17 +265,6 @@

    How web browsers an - - diff --git a/web-development-beginner-tutorial/post/a-close-look-at-the-www/introduction/index.html b/web-development-beginner-tutorial/post/a-close-look-at-the-www/introduction/index.html index d151e33..affa3aa 100644 --- a/web-development-beginner-tutorial/post/a-close-look-at-the-www/introduction/index.html +++ b/web-development-beginner-tutorial/post/a-close-look-at-the-www/introduction/index.html @@ -9,7 +9,6 @@ - @@ -79,16 +78,6 @@

    - @@ -97,221 +96,6 @@

    How web browsers find web servers

    - -

    Web browsers and web servers talk to each other over the Internet. It is the client - the browser - which initiates the -exchange. What triggers a browser to do so is the user who enters a URL into the address bar, for example: -http://www.example.com.

    - -

    The Internet is a network of millions of servers distributed all over the world. One of this million of servers serves -the www.example.com website. How does your browser connect to exactly this one server?

    - -

    The first thing the browser needs to do to in its quest to find the right server is to translate the domain name you -gave it - www.example.com - into an actual Internet address, which is a number, not a name.

    - -

    To do so, the browser utilizes an Internet component which is not a part of the World Wide Web itself, but plays a -crucial role in making it more comfortable to use: the Domain Name System, or DNS.

    - -

    You can think of the DNS as a huge telephone book. You know the name of a person, and you use it to look up their -telephone number. The DNS offers the same service for browsers - the browser queries the DNS with a domain name like -www.example.com, and the DNS tells the browser the Internet address.

    - -

    You can also query the Domain Name System yourself, from the command line of your virtual Linux box.

    - -

    To get to a command line, you need to start a Terminal application. To do so, simply click on the Ubuntu symbol in the -upper left corner of your Linux desktop. In the search dialogue which opens, type terminal.

    - -

    You will get a list of three or four applications as the search result - simply click on the first result which is -name “Terminal”, the one with the black and white icon of a window with a >_ symbol in it.

    - -

    A new application window opens which provides a text-based interface - a command line.

    - -

    At the so-called prompt, which probably looks like this:

    - -
    yourname@ubuntu:~$
    -
    - -

    you are able to type commands which the Linux system then executes.

    - -

    One of this commands is called dig. We can use dig to ask the Domain Name System for the Internet address of -www.example.com like so:

    - -
    yourname@ubuntu:~$ dig www.example.com A
    -
    - -

    Enter this command, and then hit enter. With this, you start the command line application dig with two parameters: the -name for which to look up information from the DNS, and the type of information you want to look up, in this case A, -which stands for Internet Protocol address version 4, or IPv4 address, or, as version 4 is still the predominant -Internet Protocol version, simply IP address.

    - -

    As a result, your terminal window will output a text block similar to this one:

    - -
    ; <<>> DiG 9.10.3-P4-Ubuntu <<>> www.example.com A
    -;; global options: +cmd
    -;; Got answer:
    -;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51563
    -;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
    -
    -;; OPT PSEUDOSECTION:
    -; EDNS: version: 0, flags:; udp: 4096
    -;; QUESTION SECTION:
    -;www.example.com.       IN  A
    -
    -;; ANSWER SECTION:
    -www.example.com.    7157    IN  A   93.184.216.34
    -
    -;; Query time: 12 msec
    -;; SERVER: 127.0.1.1#53(127.0.1.1)
    -;; WHEN: Tue May 30 08:30:17 CEST 2017
    -;; MSG SIZE  rcvd: 60
    -
    - -

    While there is a lot of additional information here which we will ignore for now, we also get the information we asked -for, on line 13: The IPv4 address of www.example.com is 93.184.216.34.

    - -

    When you ask your browser to open www.example.com, it does the same - it tries to retrieve this numeric address via -the DNS.

    - -

    It doesn’t start the dig command in the background - that command is for human users. Instead, it issues the query -directly, using its own program code. The details of this do not matter to us.

    - -

    You can sometimes even see the browser doing this step - especially if your internet connection is not the fastest, you -can see for a brief moment a status message in the lower left corner of the browser window, stating something similar to -“Looking up www.example.com…”.

    - -

    So, you have entered the address www.example.com into the address bar of your browser, you hit enter, and your browser -uses the Domain Name System to look up the IP address of the server system which serves the www.example.com website.

    - -

    How computers on the Internet establish a network connection

    - -

    What happens next?

    - -

    Using the IP address it looked up, the browser can now attempt to establish a network connection to the target server.

    - -

    To do so, the browser uses the mechanisms of the Internet Protocol, whose job is to make network connections between -computer systems possible. The most important mechanism for this is called routing. Routing is the process of creating -a path between a source node on the Internet (your computer) and a target node on the Internet (the computer system with -IP address 93.184.216.34, in our example).

    - -

    The beauty of this routing mechanism is that while your computer needs to know the exact target address it wants to talk -to, it doesn’t need to bother how to get its data to this target address.

    - -

    Again, a metaphor from real life comes to mind.

    - -

    Let’s assume you want to write a letter to, say, the European Organization for Nuclear Research in Switzerland, also -known as CERN. In order to do so, you need a target postal address, and you need to know the next post station where -you can mail the letter - and nothing more. The postal system takes care of the rest, and the exact route of the letter -and the intermediary post stations involved is neither known to you nor important to you. You can rest assured that the -system will route your letter correctly to its destination.

    - -

    With Internet Protocol routing, it’s the same: Your computer knows the target address, plus it knows the address of its -own “next” Internet “station” - this is called the default gateway. When you connect your computer to the Wifi box in -your home, the IP address of the Wifi box becomes the default gateway of your computer, and a server system from your -Internet provider is in turn the default gateway of your Wifi box.

    - -

    By delivering data to this default gateway, the data packet starts to travel through the Internet towards its -destination through many different systems - or “nodes” - on the Internet, bringing it closer to its target with each -step.

    - -

    Each node simply handing over the data packet to its one “next” node of course isn’t enough, because that would -only work if all nodes, including your source and target node, were connected serially on the Internet. But the Internet -is a network of many nodes interconnected with each other.

    - -

    Thus, for routing to be useful, several nodes on the Internet have multiple “next nodes” configured, and depending -on the IP address of the target system, will decide to route the data packet in one direction or the other:

    - -
                                                                       NodeJ  
    -                                                                    ^     
    -                                                                   /      
    -                                                                  /       
    -                             NodeC  -->  NodeG  -->  NodeI  -->  NodeK
    -                              ^            \                                 
    -                             /              \                                
    -                            /                \                               
    -                           /                  v                              
    -Source  -->  NodeA  -->  NodeB              NodeH                           
    -                          /\
    -                         /  \
    -                        /    \
    -                       v      \
    -                     NodeD     v
    -                             NodeE  -->  Target
    -                                         (93.184.216.34)
    -
    - -

    The above diagram is meant to be a very simplified illustration of the logical structure of a very tiny part of the -Internet.

    - -

    The Source node could be your computer, which has NodeA (probably your DSL router) as its default gateway. When -your computer tries to reach the node with IP 93.184.216.34, it has no choice but to hand over data to the only node it -knows, NodeA. NodeA also only has one default gateway (probably a system operated by your Internet provider), NodeB.

    - -

    NodeB, however, has routes to multiple other nodes, NodeC, NodeD and NodeE, and it also knows which of these -nodes is the best next hop for a data packet addressed to 93.184.216.34.

    - -

    NodeE, then, has a direct route to the target node, and can deliver the data packet.

    - -

    Thus, Source -> A -> B -> E -> Target is the route over which your computer and the target system can establish a -connection.

    - -

    This routing capability is the foundation of the Internet - it allows two computer systems to exchange data with each -other.

    - -

    How computer programs talk to each other over the Internet

    - -

    By now, we have established a general understanding of how computers find other computers on the Internet, and how they -can establish a network connection via IP addresses and data packet routing using these addresses.

    - -

    We now need to zoom in even closer, and have a look at how exactly data is exchanged between a client and a server.

    - -

    First of all, it’s important to note that it is not computers which exchange data through the Internet, it is -applications which do.

    - -

    Our computers are just the physical shell in which our applications live, providing the physical means like network -cards and network cables (or radio signals) which enable remote applications to talk to each other.

    - -

    In our case, the two applications talking to each other are the web browser application and the web server application.

    - -

    Let’s update a diagram we have used before with more details:

    - -
    Your computer system                      Web server system
    -┌───────────────────┐                     ┌───────────────────┐
    -│                   │                     │                   │
    -│  Web browser      │                     │  Web server       │
    -│  application      │                     │  application      │
    -│  ┌────────────┐   │ requests content    │  ┌────────────┐   │
    -│  │          --│---│---------------------│--│-->         │   │
    -│  │            │   │                     │  │            │   │
    -│  │            │   │                     │  │            │   │
    -│  │            │   │                     │  │            │   │
    -│  │            │   │                     │  │            │   │
    -│  │         <--│---│---------------------│--│--          │   │
    -│  └────────────┘   │       responds with │  └────────────┘   │
    -│                   │             content │                   │
    -│                   │                     │                   │
    -└───────────────────┘                     └───────────────────┘
    -
    - -

    As you can see, the word server is used ambigously: it can mean the physical machine - the hardware - which is -connected to a network like the Internet in order to serve data (e.g. a web server for web pages, a file server for -files, a mail server for mails), but it can also mean the application - the software - which does the serving of web -pages, files, or mails.

    - -

    To distinguish between these two, I’m more precise in this text: I will talk about the server application when talking -about the piece of software which serves web pages, and about the server system when talking about the computer which -runs the server application.

    - -

    The Internet mechanisms we have seen so far - DNS, IP addressing, and routing - are sufficient to establish a network -connection between two computer systems, but not for making their applications talk to each other. If that was the case

    - -

    How web browsers and web servers talk to each other

    - -

    Let’s zoom even further in. We have learned how your web browser is able to find the IP address of the web server it -wants to request using the Domain Name System, and we have learned how your web browser can establish a connection to -the web server system available under this IP address using the routing mechanisms of the Internet.

    - -

    Now that a connection is established, we will have a look at the actual data exchange.