-
Notifications
You must be signed in to change notification settings - Fork 961
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updates script to create paths and use v6 * Removes mock data for v4 and v5 * Adds mock data for v6 * Updates mockserver to work with v6
- Loading branch information
1 parent
af9eff7
commit 9b31ec9
Showing
37 changed files
with
57 additions
and
5,586 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,43 @@ | ||
const axios = require('axios'); | ||
const fs = require('fs'); | ||
|
||
const writeJSON = (fileName, obj, encoding = 'utf8') => fs.writeFileSync(fileName, JSON.stringify(obj), encoding); | ||
const writeJSON = (fileName, obj, encoding = 'utf8') => | ||
fs.writeFileSync(fileName, JSON.stringify(obj), encoding); | ||
|
||
const fetchAndStoreData = async (url, savePath) => axios.get(url).then((res) => writeJSON(savePath, res.data)); | ||
const fetchAndStoreData = async (url, savePath) => { | ||
// Create folder for savePath if it doesn't exist | ||
const saveDir = savePath.split('/').slice(0, -1).join('/'); | ||
await fs.promises.mkdir(saveDir, { recursive: true }).catch(console.error); | ||
|
||
const CORE_URL = 'http://localhost:8001/v5'; | ||
return axios.get(url).then((res) => writeJSON(savePath, res.data)); | ||
}; | ||
|
||
const CORE_URL = 'http://localhost:8001/v6'; | ||
const timeAggregates = ['hourly', 'daily', 'monthly', 'yearly']; | ||
const historyZones = ['UA', 'DK-DK2']; | ||
const detailsZones = ['UA', 'DK-DK2']; | ||
|
||
const generateMockData = async () => { | ||
timeAggregates.forEach(async (agg) => { | ||
try { | ||
await fetchAndStoreData( | ||
`${CORE_URL}/state/${agg}`, | ||
`./public/v6/state/${agg}.json` | ||
); | ||
|
||
timeAggregates.forEach(async (agg) => { | ||
await fetchAndStoreData(`${CORE_URL}/state/${agg}`, `./public/v5/state/${agg}.json`); | ||
await fetchAndStoreData(`${CORE_URL}/history/${agg}?countryCode=DE`, `./public/v5/history/${agg}.json`); // default history data | ||
historyZones.forEach(async (zoneId) => { | ||
await fetchAndStoreData( | ||
`${CORE_URL}/history/${agg}?countryCode=${zoneId}`, | ||
`./public/v5/history/${zoneId}/${agg}.json` | ||
); | ||
await fetchAndStoreData( | ||
`${CORE_URL}/details/${agg}/DE`, | ||
`./public/v6/details/${agg}.json` | ||
); // default details data | ||
detailsZones.forEach(async (zoneId) => { | ||
await fetchAndStoreData( | ||
`${CORE_URL}/details/${agg}/${zoneId}`, | ||
`./public/v6/details/${zoneId}/${agg}.json` | ||
); | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
generateMockData(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.