Nodejs: cd my-journey00
Tags: javascript, node, programming, android
Published: 2022-05-02 19:45:21

Last night I wrote my very first Nodejs program, server (they wouldn't let me call it program for buzzword sake) on port 8080 walking to the restroom on a 16gigabyte ROM, 1 thousand megabyte RAM inside the 9th version of the Android distro within the Termux CLI, ladies and gentlemen, ItelA56.


![Node.js runtime on Termux](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hkr6te2lz14vokfn1gy.png)


![Node file initiated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ouvgqdkq5txcnh2jzku6.png)


![Node server running on port8080](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1emh4kzivdmwm0tvu6e1.png)
It does a pretty neat job. Last night was the first time I had any experience with _backend_, I must say the logic in it is fine, very fine. Prior to this, I had always dwelled on the _frontend_ of the Web and only done anything Terminal related on a desktop OS and lightweight android compilers for other programming languages. 

All these wouldn't had made sense to me if I read this to myself yesterday but it all makes sense now. _Backend_ logic. 

Today I learned about "**Node Modules**" and what they are, they are like JavaScript libraries _(like the Math library with Objects and methods, like the react library used within the head of an html file)_ which can be imported and exported using a _method_, **require()** to call it.

Quick check: While searching for definition of a JS library even though I "knew" it I saw a blog post of [skillcrush](Skillcrush.com) on the Google results display say: _"JavaScript libraries are like pieces of furniture that add style and function to an already constructed house. Frameworks, on the other hand, are a template you use to build the house itself._" And that makes sense in the comparison with the Math library and React library. They add to, so I don't have to "reinvent the wheel". 

I also learned that a module is different from the Nodejs file, the node file as I've observed carries the listen _method_, **listen()**. Wait I missed one part. There's a module called "http" which is an inbuilt module that allows messages to be sent via HTTP (Hypertext Transfer Protocol) through a server  that be included (require(d)) to the main nodejs file in order to be able to create a server, because it contains the **createserver()** _method_ and **listen()** _method_.

To call use a module, the _require_ method is required and storing that _required_ module in a variable to used with methods. 

```javascript 
var example = require('http');
//require(d) http module is stored in the variable, example.
```

Using this information, I created a nodejs file (edited the _Hello, World!_ out) and a module file in the same folder and exported it to the main file using the "exports" keyword in the module code so as to enable it function "outside" within a server code. The module was a JS program to display the current date and time using the date() method. 

![Node-file-source-code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2w3f6g066n6gwosrzp9m.png)


![Node-module](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yzdhzcnslqcfnga0tf85.png)


![Nodeup](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2anxahofgmgf49ownnr.png)


_This is logic and sheer programming, the backend.
 This is the closest you can be to machine._

Things learned: Logic, Import, export, modules, Library, Framework, Nodejs, backend, server. 

Resource used: [W3Schools](w3schools.com), 
 [Skillcrush](Skillcrush.com) 

Node (from the Latin word nodus, meaning to knot, an intersection, an edge, a point, a lump.) is a basic unit of a data structure. In graph theory, a graph is a way to describe many things which have relationships. The things are called nodes, the relationships connecting the nodes are called edges. Connecting edges, points, Node. Nodejs. 


Day 1 of Problem solving, backend.