0
0
mirror of https://github.com/fawazahmed0/exchange-api.git synced 2025-08-22 18:38:37 +00:00
This commit is contained in:
Fawaz Ahmed 2024-02-29 20:26:35 +05:30
parent 17f2cf42f8
commit fa91b18144

View File

@ -44,6 +44,7 @@ for (const [key, value] of Object.entries(allcurr)) { allcurrLower[value.toLower
const dateToday = new Date().toISOString().substring(0, 10) const dateToday = new Date().toISOString().substring(0, 10)
const latestDir = path.join(__dirname, 'latest')
begin() begin()
// Begins the program // Begins the program
@ -51,7 +52,7 @@ async function begin() {
// launch the browser // launch the browser
// await launchBrowser() // await launchBrowser()
const latestDir = path.join(__dirname, 'latest')
const currJSON = await getCurrencies() const currJSON = await getCurrencies()
// Get & Save All the available currencies in api // Get & Save All the available currencies in api
@ -180,12 +181,12 @@ function sortObjByKeys(obj) {
// Generates the api files // Generates the api files
async function generateFiles(googBingCurrJSON) { async function generateFiles(googBingCurrJSON) {
const currenciesDir = path.join(__dirname, 'latest', 'currencies') const currenciesDir = path.join(latestDir, 'currencies')
for (const [fromKey, fromValue] of Object.entries(googBingCurrJSON)) { for (const [fromKey, fromValue] of Object.entries(googBingCurrJSON)) {
const tempObj = {} const tempObj = {}
tempObj['date'] = dateToday; tempObj['date'] = dateToday;
tempObj[fromKey] = {} tempObj[fromKey] = {}
const fromKeyDir = path.join(__dirname, 'latest', 'currencies', fromKey) const fromKeyDir = path.join(latestDir, 'currencies', fromKey)
fs.mkdirSync(fromKeyDir, { fs.mkdirSync(fromKeyDir, {
recursive: true recursive: true
}) })