Skip to content
This repository was archived by the owner on Oct 2, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions zip-api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,25 @@ app.get('/', (req, res) => {
res.json({test: 'Yay'});
});


app.get('/zip/:zipcode', (req, res) => {
// fill in...
const zip_records = zipdb.byZip[req.params.zipcode];
if (zip_records === undefined){
res.sendStatus(404);
}
else {
res.json(zip_records);
}
});


app.get('/city/:cityname', (req, res) => {
// fill in...
const cityRecords = zipdb.byCity[req.params.cityname];
if(cityRecords === undefined) {
res.sendStatus(404);
}
else {
res.json(cityRecords);
}
});


Expand Down
30 changes: 15 additions & 15 deletions zip-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion zip-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Simple API backend for CTP lecture.",
"main": "app.js",
"scripts": {
"start": "node app.js"
"start": "nodemon -L app.js"
},
"author": "Edgardo Molina",
"license": "ISC",
Expand Down