ENTD261 Week 4 Introduction: Node.js

Learning Goal: I’m working on a programming exercise and need an explanation and answer to help me learn.

Course name : ENTD261

Week 4: Node.js

Instructions

Create a simple Node.js server (Save as w4_fougnigue_soro.js) . Create a restful application similar to the one in lesson 4 (ReSTFul Web Services). Document the routing table, and the application you created.

Submit your week 4 work in w4_fougnigue_soro.txt (Please save the file as a text file and upload the text file here for final review.)

Note: node MUST be installed in the entd261 folder. Your code must be saved to the entd261 folder. node cannot be installed in any other folder. Be sure you have done this, or the code will not run in the command line.

Please refer to the attached sample solution file, w4_first_lastName.txt, for help. In place of first and lastName in the file name make sure your first and last names are present.

Requirements Points
Comment block. Instructions on how to run the code with examples 20
Code documentation and comments. 10
Assignment code including creating command line /URL parameter

(see routing table on how to document the URLs)

70
TOTAL POINTS 100

Reminder: This is what your ENTD261 folder should look like with node installed.

Attachments

w4_first_lastName.txt

(2.15 KB)

/*******************************************************************

***

***ENTD261

***

***Week 4

*** How to run: node w4_first_lastName.js

*** This Node.js app will display the inventory of a car shop.

***once the server is running, you will get

***Express server listening on port 44444

***from any browser enter http://localhost:44444/

*******************************************************************/

//setup

var express =require (“express”);

var http = require (“http”);

var app = express();

// run the server

app.listen(44444, function(){

console.log(“server is running on port 44444”);

})

// <<< here is the Model, the data storage

var vehicles = [

{id: 0, make: ‘toyota’, model: ‘corola’, year: 2019, color: ‘blue’},

{id: 1, make: ‘jeep’, model: ‘patriot’, year: 2016, color: ‘red’},

{id: 2, make: ‘honda’, model: ‘civic’, year: 2018, color: ‘white’},

{id: 3, make: ‘chevrolet’, model: ‘cruze’, year: 2019, color: ‘silver’}

];

// http://localhost:44444// general route

// here is the refer

app.get(“/”, function(req,res){

var message = “”

message += “<center><h1> Welcome to Pemon’s Car Shop </h1></center>”

message += “<center><h2>use the following </h2></center><br/>”

message += “<center> http://localhost:44444/about_us</center><br>”

message += “<center>http://localhost:44444/vehicles</center><br>”

message += “<center>http://localhost:44444/vehicles/3</center><br>”

res.send(message);

});

// <<< routes = controller

// http://localhost:44444/about_us// about_usroute

app.get(“/about_us”, function(req,res){

res.send(“We are here to serve you”);

});

// http://localhost:44444/vehicles// load and display all vehicles

app.get(‘/vehicles’, function(req, res){

res.send(JSON.stringify(vehicles));

});

// http://localhost:44444/vehicles/3// load and display vehicle id 3

app.get(‘/vehicles/:id’, function(req, res){

if(req.params.id > (vehicles.length -1) || req.params.id < 0){

res.statusCode = 404;

res.end(‘Vehicle Not Found’);

}

res.send(JSON.stringify(vehicles[req.params.id]))

});

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more