NodeJs

Module

It is a function that could let us to perform a certain task. The main purpose of the module creation is to declare and initialize the module at some point where any one who want to use the module can easly import in their .js file. The declaration and definition of a module can be made using a keyword exports along with the name of module. Take a look the following example

Figure 1.4 Declaring and Initializing Module

Once the module is declared and defined, It will be included in the application using a keyword require indicating the path that the module is actually located. once the module is imported, it is possible to use it in our implementation any where necessary.

Figure 1.5 Importing Module

Reading URL- ‘req.url’

This is a server that is reading URL and write back as outcome to the client the path of the URL. The path meaning, any extension added on the Domain is labeled as Path The Parameter req could let to get information about path of the URL. The application of getting the path from the URL is as follow

Figure 1.6 Reading URL Path

Parsing URL Query – ‘url.parse’ & query

Parsing Query is one of the thing that could let us to query and work with the path of the URL. The parse will be performed using a method parse and .query. The application will be as follow considering that the parse is taken place the actually URL that the user is requesting

Figure 1.7 Parsing the URL Query

Note : – There are a lot of built in function in Js that could let us to have a lot of function in our development. Therefore We will address this discussion furhter in the Advance topic of Javascript.