feat: make 0 rates not appear
This commit is contained in:
+9
-30
@@ -1,7 +1,4 @@
|
|||||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||||
|
|
||||||
import { error, log } from "console";
|
|
||||||
|
|
||||||
const { exec } = require("child_process");
|
const { exec } = require("child_process");
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
@@ -99,7 +96,7 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
.catch((error) => console.log("error", error));
|
.catch((error) => console.log("error", error));
|
||||||
|
|
||||||
const curlCommand = `curl 'https://acemoneytransfer.com/make-request' \
|
const curlCommand = `curl -v 'https://acemoneytransfer.com/make-request' \
|
||||||
-H 'authority: acemoneytransfer.com' \
|
-H 'authority: acemoneytransfer.com' \
|
||||||
-H 'accept: */*' \
|
-H 'accept: */*' \
|
||||||
-H 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' \
|
-H 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' \
|
||||||
@@ -122,16 +119,15 @@ export default async (req, res) => {
|
|||||||
if (error) {
|
if (error) {
|
||||||
reject(`Error: ${error.message}`);
|
reject(`Error: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
exec("curl --version", (error, stdout, stderr) => console.log(`Curl Version ${stdout}`))
|
||||||
try {
|
try {
|
||||||
const parsed_rate = JSON.parse(stdout);
|
const parsed_rate = JSON.parse(stdout);
|
||||||
console.log("Parsed Ace Rate>>>>", parsed_rate)
|
|
||||||
resolve({
|
resolve({
|
||||||
rate: parseFloat(parsed_rate.data.exchange_rate).toFixed(2),
|
rate: parseFloat(parsed_rate.data.exchange_rate).toFixed(2),
|
||||||
provider: "Ace Transfer",
|
provider: "Ace Transfer",
|
||||||
bestRate: false,
|
bestRate: false,
|
||||||
});
|
});
|
||||||
} catch (parseError) {
|
} catch (parseError) {
|
||||||
console.log("Ace Exception>>>>", parseError)
|
|
||||||
reject(parseError.message);
|
reject(parseError.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -144,8 +140,8 @@ export default async (req, res) => {
|
|||||||
href: "https://acemoneytransfer.com/referral-link/3056004",
|
href: "https://acemoneytransfer.com/referral-link/3056004",
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.catch((result) => {
|
.catch((error) => {
|
||||||
console.log("ace_call_exceptions>>>>", result);
|
console.error("Error Calling Ace>>>", error);
|
||||||
return {
|
return {
|
||||||
rate: 0.0,
|
rate: 0.0,
|
||||||
provider: "Ace Transfer",
|
provider: "Ace Transfer",
|
||||||
@@ -154,25 +150,6 @@ export default async (req, res) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const remitlyCurlCommand = `curl --location 'https://api.remitly.io/v5/pricing/estimates?amount=100.00%20EUR&anchor=SEND&conduit=NLD%3AEUR-NGA%3ANGN&purpose=OTHER' \
|
|
||||||
--header 'accept: application/json' \
|
|
||||||
--header 'accept-language: en, en;q=0.5' \
|
|
||||||
--header 'content-type: application/json' \
|
|
||||||
--header 'origin: https://www.remitly.com' \
|
|
||||||
--header 'priority: u=1, i' \
|
|
||||||
--header 'referer: https://www.remitly.com/' \
|
|
||||||
--header 'remitly-deviceenvironmentid: 3RoCMKdq1DauxuTShWkZhQpbQm6AKs0ALkUxILdiIWPuJfxDIokB1w0JII8kqhj1q8ZXWAPFoELwpTlRRKYfiwWoihvXkYcDCYnoACCVAASj' \
|
|
||||||
--header 'sec-ch-ua: "Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"' \
|
|
||||||
--header 'sec-ch-ua-mobile: ?0' \
|
|
||||||
--header 'sec-ch-ua-platform: "macOS"' \
|
|
||||||
--header 'sec-fetch-dest: empty' \
|
|
||||||
--header 'sec-fetch-mode: cors' \
|
|
||||||
--header 'sec-fetch-site: cross-site' \
|
|
||||||
--header 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36' \
|
|
||||||
--header 'x-remitly-perf-reqsize: 0' \
|
|
||||||
--header 'x-remitly-perf-starttime: 1714932144397'
|
|
||||||
`;
|
|
||||||
|
|
||||||
const remitly_call = new Promise((resolve, reject) => {
|
const remitly_call = new Promise((resolve, reject) => {
|
||||||
fetch("https://api.remitly.io/v2/calculator/estimate?conduit=NLD%3AEUR-NGA%3ANGN&anchor=SEND&amount=100+EUR&purpose=OTHER&strict_promo=false", {
|
fetch("https://api.remitly.io/v2/calculator/estimate?conduit=NLD%3AEUR-NGA%3ANGN&anchor=SEND&amount=100+EUR&purpose=OTHER&strict_promo=false", {
|
||||||
"headers": {
|
"headers": {
|
||||||
@@ -195,7 +172,7 @@ export default async (req, res) => {
|
|||||||
}).then(result => resolve(result.json())).catch(error => reject(error));
|
}).then(result => resolve(result.json())).catch(error => reject(error));
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
console.log("Remitly<<<<<<<", result)
|
// console.log("Remitly<<<<<<<", result)
|
||||||
return {
|
return {
|
||||||
rate: parseFloat(result[0].base_rate).toFixed(2),
|
rate: parseFloat(result[0].base_rate).toFixed(2),
|
||||||
provider: "Remitly",
|
provider: "Remitly",
|
||||||
@@ -204,7 +181,7 @@ export default async (req, res) => {
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Error Calling Ace>>>", error);
|
console.error("Error Calling Remitly>>>", error);
|
||||||
return {
|
return {
|
||||||
rate: 0.0,
|
rate: 0.0,
|
||||||
provider: "Ace Transfer",
|
provider: "Ace Transfer",
|
||||||
@@ -237,7 +214,7 @@ export default async (req, res) => {
|
|||||||
.catch((error) => reject(error));
|
.catch((error) => reject(error));
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
console.log("NALA<<<<<<<", result)
|
// console.log("NALA<<<<<<<", result)
|
||||||
return {
|
return {
|
||||||
rate: parseFloat(result.data[5].rate).toFixed(2),
|
rate: parseFloat(result.data[5].rate).toFixed(2),
|
||||||
provider: "Nala",
|
provider: "Nala",
|
||||||
@@ -296,5 +273,7 @@ export default async (req, res) => {
|
|||||||
object.bestRate = index === maxRateIndex;
|
object.bestRate = index === maxRateIndex;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rates = rates.filter(rate => rate.rate > 0)
|
||||||
|
|
||||||
return res.status(200).json(rates);
|
return res.status(200).json(rates);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user