-
-
Save codecademydev/49bd6c5578762f4bc9447f2b9ecac9b4 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const PORT = process.env.PORT || 4001; | |
const currencies = { | |
diram: { | |
countries: ['UAE', 'Morocco'], | |
}, | |
real: { | |
countries: ['Brazil'], | |
}, | |
dinar: { | |
countries: ['Algeria', 'Bahrain', 'Jordan', 'Kuwait'], | |
}, | |
vatu: { | |
countries: ['Vanuatu'], | |
}, | |
shilling: { | |
countries: ['Tanzania', 'Uganda', 'Somalia', 'Kenya'], | |
}, | |
}; | |
app.listen(PORT, () => { | |
console.log(`Server is listening on port ${PORT}`); | |
}); | |
app.put('/currencies/:name/countries', (req, res, next) => { | |
const currencyName = req.params.name; | |
const newCountries = req.query; | |
currencies[currencyName] = newCountries; | |
res.send(currencies[currencyName]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment