1842week8 pt1 Nodeserver
1842week8 pt1 Nodeserver
Node.js server
Matt Prichard
Introduction
NoSQL recap from week 6
Node js server
Recap – NoSQL
Please read these articles !!!
Very useful for your final report.
https://www.sitepoint.com/sql-vs-nosql-differences/
https://www.sitepoint.com/sql-vs-nosql-choose/
Recap -Running Node locally
• For these examples I am running
the files from my G Drive
npm –v
G Drive – new folder npmtest
Create test.js and save to the
new folder
Run node
Open the Node command prompt, navigate to where the file is
cd folder1/folder2/folder3/
cd ../../../
2. Waits while the file system opens and reads the file.
3. When the file system has opened and read the file, the server returns
the content to the client.
Node.js eliminates the waiting, and simply continues with the next request.
• Node.js files must be initiated on the server before having any effect
If the body has single statement or expression, you can write arrow
function as:
Further
reading
https://www.w3schools.com/Js/js_arrow_function.asp
https://www.freecodecamp.org/news/arrow-function-javascript-tutorial-how-to-decla
re-a-js-function-with-the-new-es6-syntax/
Create new file
• Node.js provides capabilities to create your own web server which will
handle HTTP requests asynchronously. You can use IIS or Apache to run
Node.js web applications but it is recommended to use Node.js web
server.
Create Node.js web server
Node.js has a built-in module called HTTP, which allows Node.js to
transfer data over the Hyper-Text Transfer Protocol (HTTP).
Note I have a new file server1, yours can still be the same file
that it sends the response. To send a response, first it sets the response
body using write() method. Finally, Node.js web server sends the response
https://www.tutorialsteacher.com/nodejs/create-nodejs-web-server
https://www.tutorialspoint.com/nodejs/nodejs_response_object.htm
https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/
https://www.w3schools.com/nodejs/nodejs_http.asp