Browse Source

add user

main
Martin 4 years ago
parent
commit
9b5f7e901e
  1. 27
      index.js
  2. 8535
      package-lock.json
  3. 5020
      yarn.lock

27
index.js

@ -4,11 +4,32 @@ import axios from 'axios';
const app = fastify({ logger: true }); const app = fastify({ logger: true });
const CAT_FACT_URL = 'https://cat-fact.herokuapp.com/facts/random'
const RANDOM_FOX_URL = 'https://randomfox.ca/floof/'
const COUNTRY_HOLIDAYS_URL = 'https://date.nager.at/api/v3/publicholidays/2022/'
const getCatFacts = async (amount) => await axios.get(CAT_FACT_URL + '?amount=' + amount)
.then((response) => response.data.map(item => item.text))
.catch(() => null)
const getFoxPicture = async () => await axios.get(RANDOM_FOX_URL)
.then((response) => response.data.image)
.catch(() => null)
const getCountryHolidays = async (countryCode) => await axios.get(COUNTRY_HOLIDAYS_URL + countryCode)
.then((response) => response.data)
.catch(() => null)
app.post('/', async (req, res) => { app.post('/', async (req, res) => {
let catFacts = await getCatFacts(3)
let foxPicture = await getFoxPicture()
let holidays = await getCountryHolidays(req.body?.countryCode ?? "FR")
return { return {
message: `Welcome to Node Babel with ${
req.body?.testValue ?? 'no testValue'
}`,
foxPicture,
catFacts,
holidays,
}; };
}); });

8535
package-lock.json
File diff suppressed because it is too large
View File

5020
yarn.lock
File diff suppressed because it is too large
View File

Loading…
Cancel
Save