Programming

22. Long Polling Chat, POST Reading. Pt 2.

So, whatever we type, we see the same message to be sent. Let us fix it. We send messages with a POST method. In order to read this method from req, we need to work with it as with a stream. So, let us look at the following scheme that describes a request’s lifecycle, in particular of the req and res objects.

Category: Programming
0

22. Long Polling Chat, POST Reading. Pt 1.

Hey all! The aim of our lesson for today is to learn how to create a Node.js chat. Our first chat will be rather simple.

Category: Programming
0

21. Node.js Lessons. Writable Response Stream (res), Pipe Method. Pt.2

Upon the file ending you will see the end event, in the handler of which we will end our response by calling res.end. Thus, the outgoing connection will be closed for the file has been completely sent. The resulting code is quite versatile:

Category: Programming
0

21. Node.js Lessons. Writable Response Stream (res), Pipe Method. Pt.1

Our next step will be using the streams to work with network connections. And we will start from delivering files to a visitor. As you may remember, we’ve already had a task like this: if a visitor requires the following url, you will give him the file. Let us create a file pipe.js with the following code (for your convenience, you can download code' lesson from the repository because we'll need an HTML file from there):

Category: Programming
0

20. Node.js Lessons. Data Streams in Node.JS, fs.ReadStream

Hey all! Our topic for today is Data Streams In Node.js. We will try to learn all the aspects in details for the reason it turns out that on the one hand, common browser JavaScript development lack streams. And on the other hand, knowing and understanding stream principles is necessary for seamless server development because a stream is a versatile way of work with data sources universally used.

Category: Programming
0

19. Node.js Lessons. Safe Way to a FS File and Path

This article will deal with how to create a web server in Node.js, which will return a file to a user from a public directory. You may wonder: why do we need Node.js here? Why can’t we use another server? You question surely does make sense. Yes, for returning files other servers are generally more effective. From the other side, Node.js works pretty well, too. Second, before returning a file it can also perform some intellectual activities: for example, refer to a database, check out whether a user is permitted to access the file and give the file to him, if it’s permitted.

Category: Programming
0

18. Node.js Lessons. Work With Files. Fs Module

Dear friends! The key goal of our today’s lesson is to learn how to work with binary data and file system. Node.js contains fs module to work with files, which includes a number of functions for various operations with files and directories.

Category: Programming
0

17. Node.js Lessons. Timers, Differences from Browser, ref and ref

Hey, guys! Our today’s article will tell you about Node.js timers. Here we will try to tell you about all the differences existing between browser and Node.js timers. So, let us refer to our technical materials and see a number of similar methods:

Category: Programming
0

16. Node.js Lessons. Event Loop, libUV Library. Part 2

On that joyful note JavaScript execution ends, and libUV checks whether there is any watcher that can be activated, which means whether there is any internal handler. If there is no handler, the whole Node.js process gets finished, as well as the whole event loop, too. In our case, one watcher of this kind, in particular a port 3000 handler, was installed. That’s why a Node.js process is not going to finish, but will get a stand-by mode. It will stay in this mode until some reason to get activated occurs – for example, new input-output events.

Category: Programming
0

16. Node.js Lessons. Event Loop, libUV Library. Part 1

Hey, guys! If your habit is to learn something deeply and thoroughly, this article is for you. Here we will try to answer the questions that you will have sooner or later in the process of development. These answers require deep understanding of how Node.js works. For example, here (serverAsync.js see the files of our previous lesson) an asynchronous call is used for reading a file:

Category: Programming
0

Sign in

Forgot password?

Or use a social network account

 

By Signing In \ Signing Up, you agree to our privacy policy

Password recovery

You can also try to

Or use a social network account

 

By Signing In \ Signing Up, you agree to our privacy policy