Answer :
Below is the implementation of the zillow.js server that fulfills the given specifications using Express:
javascript
Copy code
const express = require('express');
const app = express();
const port = process.argv[2];
const houses = [
{ price: 240000, city: "baltimore" },
{ price: 300000, city: "austin" },
{ price: 400000, city: "austin" },
{ price: 1000000, city: "seattle" },
{ price: 325000, city: "baltimore" },
{ price: 550000, city: "seattle" },
{ price: 250000, city: "boston" }
];
app.get('/v1/zillow/zestimate', (req, res) => {
const { sqft, bed, bath } = req.query;
if (!sqft || !bed || !bath) {
res.sendStatus(400);
return;
}
const zestimate = sqft * bed * bath * 10;
res.json({ zestimate });
});
app.get('/v1/zillow/houses', (req, res) => {
const { city } = req.query;
if (city) {
const filteredHouses = houses.filter((house) => house.city === city);
res.json(filteredHouses);
} else {
res.json([]);
}
});
app.get('/v1/zillow/prices', (req, res) => {
const { usd } = req.query;
if (!usd) {
res.sendStatus(400);
return;
}
const filteredHouses = houses.filter((house) => house.price <= usd);
res.json(filteredHouses);
});
app.use((req, res) => {
res.sendStatus(404);
});
app.listen(port, () => {
console.log(`Server listening on port ${port}`);
});
Make sure you have Express installed (npm install express) before running this program.
Know more about javascripthere;
https://brainly.com/question/16698901
#SPJ11