Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created December 25, 2018 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/49bd6c5578762f4bc9447f2b9ecac9b4 to your computer and use it in GitHub Desktop.
Save codecademydev/49bd6c5578762f4bc9447f2b9ecac9b4 to your computer and use it in GitHub Desktop.
Codecademy export
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