|
|
@ -1,21 +1,32 @@ |
|
|
import fastify from 'fastify'; |
|
|
import fastify from 'fastify'; |
|
|
// see axios doc on how to use it
|
|
|
|
|
|
import axios from 'axios'; |
|
|
import axios from 'axios'; |
|
|
|
|
|
|
|
|
const app = fastify({ logger: true }); |
|
|
const app = fastify({ logger: true }); |
|
|
|
|
|
|
|
|
app.get('/', async (req, res) => { |
|
|
app.get('/', async (req, res) => { |
|
|
return { |
|
|
return { |
|
|
message: `Welcome to Node Babel with ${ |
|
|
|
|
|
req.body?.testValue ?? 'no testValue' |
|
|
|
|
|
}`,
|
|
|
|
|
|
|
|
|
catfacts: getCatFacts(), |
|
|
|
|
|
foxes: getFoxDay(), |
|
|
|
|
|
day: getDayOfCountry() |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Run the server!
|
|
|
|
|
|
|
|
|
const getCatFacts = async(id) =>{ |
|
|
|
|
|
axios.get('https://cat-fact.herokuapp.com/facts/{id}').then(res => {}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const getFoxDay = async(id) =>{ |
|
|
|
|
|
axios.get('https://randomfox.ca/floof/').then(res => {}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const getDayOfCountry = async(id) =>{ |
|
|
|
|
|
axios.get('https://randomfox.ca/floof/').then(res => {}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
const start = async () => { |
|
|
const start = async () => { |
|
|
try { |
|
|
try { |
|
|
await app.listen(5000); |
|
|
await app.listen(5000); |
|
|
|
|
|
getCatFacts(1); |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
app.log.error(err); |
|
|
app.log.error(err); |
|
|
process.exit(1); |
|
|
process.exit(1); |
|
|
|