Sale!

Solved COSC484 Assignment 5

$30.00 $18.00

Original Work ?

Download Details:

  • Name: Assignment5-veygbi.zip
  • Type: zip
  • Size: 78.05 KB

Category: Tags: , You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

You cannot use the
HTTP module, only Express. If the HTTP module is used instead of Express
you will receive a 0. If you use the ES6 import statement instead of the
CommonJS require for node modules taught during lecture, you will lose 10%.
Specifications
Rich Barton, the CEO of Zillow, needs your help developing a simple API to
determine the Zestimates of houses as well as fetching housing data easily.
For this assignment, you will write an API Server that listens on the port provided by the first argument to your program to provide details about a
home.
JSON API Server
Write a server called zillow.js that serves JSON data when it receives a GET request to the path ’/v1/zillow/zestimate’. Expect the request to contain a query
string with a keys ’sqft’, ’bed’, and ’bath’ all of which will be required integers.
The Zestimate is calculated as follows: Zestimate == sqft * bed * bath * 10
and you should return to the use JSON in the following format: {zestimate:
Number }
For example: /v1/zillow/zestimate?sqft=2000&bed=3&bath=4
The JSON response should contain only the ‘zestimate’ property:
For example: {“zestimate”: 240000}
Add a second endpoint at the path ‘/v1/zillow/houses’ that accepts an optional parameter ‘city‘. If city is provided as a parameter, the return all houses
that match the given city. If no city parameter is provided, then return an
empty array []. If a city is provided and the city is not found, return an empty
array []
You will not connect to a real database, but to simulate one, use this array of
objects:
[ { price: 240000, city: “baltimore” }, { price: 300000, city: “austin” },
{ price: 400000, city: “austin” }, { price: 1000000, city: “seattle”}, { price:
1
325000, city: “baltimore” }, { price: 550000, city: “seattle” }, { price: 250000,
city: “boston” } ]
For example: /v1/zillow/houses?city=baltimore
The JSON response should contain only the the list of houses in baltimore.
For example: [{ price: 240000, city: ”baltimore” }, { price: 325000, city: ”baltimore” }]
For example: /v1/zillow/houses?city=raleigh
The JSON response should contain: []
For example: /v1/zillow/houses
The JSON response should contain: []
Add a third endpoint at the path ‘/v1/zillow/prices’ that accepts a required
parameter ‘usd‘. This will return all houses equal to or under a given price. If
no houses are under the given price, return an empty array: []
For example: /v1/zillow/prices?usd=30000
The JSON response should contain: [{ price: 240000, city: ”baltimore” }, {
price: 250000, city: ”boston” }]
For example: /v1/zillow/prices?usd=10000
The JSON response should contain: []
Please return a 200 status code if the request is correct and a 404 if the request is not correct (invalid endpoint, arguments, etc.)
Submission
Please submit the following on Blackboard:
• zillow.js