Skip to content

Latest commit

 

History

History

samples_Duuna

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Node.js examples from Düüna's book

Node.js project Directory samples_Duuna\ contains Node.js examples presented in Düüna's book "Secure Your Node.js Web Application" (The Pragmatic Programmers, 2016).

chp-3-networking Example

Executing command npm start in directory samples_Duuna\chp-3-networking\ performs two tasks:

  • it starts the server application which listen to client requests on port 3000 (defined in file config.json 1).
  • it opens the http:/127.0.0.1:3000 URL in your default web browser.

First we start the server application in a new console:

> start npm start

> [email protected] start N:\samples_Duuna\chp-3-networking
> node ./npm_scripts/start_browser.js && node .


Node runtime: v16.20.2 (x64)
Module search path: (none)
Server listening on port 3000

Then we start the client application in the current console:

> npm run client 
                              
> [email protected] client N:\samples_Duuna\chp-3-networking
> node ./npm_scripts/start_client.js   

en
hello world

de
hello world

fr
hello world

chp-4-code-injection Example

Executing command npm start in directory samples_Duuna\chp-4-code-injection\ performs two tasks:

  • it starts the server application which listen to client requests on port 3000 (defined in file config.json 1).
  • it opens the http:/127.0.0.1:3000 URL in your default web browser.
> npm start

> [email protected] start N:\samples_Duuna\chp-4-code-injection
> node ./npm_scripts/start_browser.js && node .


Node runtime: v18.20.4 (x64)
Module search path: (none)
Server listening on port 3000

Footnotes

[1] config.json

Only the template file config_TEMPLATE.json is stored in our GitHub repository. The user has to copy it to config.json and update the two JSON fields host and port as desired before running the above code examples.

mics/November 2024