Node.js examples from Bojinov's book ⬆
Directory samples_Bojinov\ contains Node.js examples presented in Bojinov's book "RESTful Web API Design with Node.js" (Packt, 2015). |
Command npm start
executes application app\app.js
which performs two tasks:
- it starts the server application which listen to client requests on port
8180
(defined in fileconfig.json
). - it opens URL
http:/127.0.0.1:8180
in our default web browser.
> cd N:\samples_Bojinov\express > npm start > express-app@0.0.1 start N:\samples_Bojinov\express > node ./npm_scripts/start_browser.js && node . Module search path: (none) Server listening on port 8180
The default browser displays the following contents in a new tab:
2019-12-07T17:53:06+01:00
Command npm start
executes application app\app.js
which performs two tasks:
- it starts the server application which listen to client requests on port
8180
(defined in fileconfig.json
). - it opens URL
http:/127.0.0.1:8180
in our default web browser.
> npm start > hello1-app@0.0.1 start N:\samples_Bojinov\hello-1 > node ./npm_scripts/start_browser.js && node . Node runtime: 18.20.4 (x64) Module search path: (none) Started Node.js http server at http://127.0.0.1:8180 requested (GET)
math
Example ▴
Command npm run test
executes all test functions contained in directory math\test
:
> npm run test > math@0.0.1 test N:\samples_Bojinov\math > nodeunit test test-math √ test_add √ test_subtract OK: 2 assertions (16ms)
mock
Example ▴
Command npm run test
executes all test functions contained in directory mock\test
, in this case test-http-module.js
:
> npm run test > mock-example@0.0.1 test N:\samples_Bojinov\mock > nodeunit test test-http-module Request processing by http-module ended √ test_handle_GET_request OK: 0 assertions (184ms)
Command npm start
executes app\app.js
which performs two tasks:
- it starts the server application which listen to client requests on port
8180
(defined in fileconfig.json
). - it opens URL
http:/127.0.0.1:8180/salut?name=tom
in our default web browser.
> npm start > routes-app@0.0.1 start N:\samples_Bojinov\routes > node ./npm_scripts/start_browser.js && node . Node runtime: 18.20.4 (x64) Module search path: N:\samples_Bojinov\\node_modules Server listening at 127.0.0.1:8180