diff --git a/.env.example b/.env.example index e671f2a7e1f..bc513cc872d 100644 --- a/.env.example +++ b/.env.example @@ -8,3 +8,4 @@ ETHERSCAN_API_KEY=insertValue GATSBY_ALGOLIA_APP_ID=insertValue GATSBY_ALGOLIA_SEARCH_KEY=insertValue GATSBY_GITHUB_TOKEN_READ_ONLY=insertValue +GATSBY_FUNCTIONS_PATH=insertValue \ No newline at end of file diff --git a/src/api/coinmetrics.js b/src/api/coinmetrics.js new file mode 100644 index 00000000000..7923aba11c5 --- /dev/null +++ b/src/api/coinmetrics.js @@ -0,0 +1,8 @@ +import { handler as lambda } from "../lambda/coinmetrics" + +async function handler(__req, res) { + const { statusCode, body } = await lambda() + res.status(statusCode).send(body) +} + +export default handler diff --git a/src/api/defipulse.js b/src/api/defipulse.js new file mode 100644 index 00000000000..9e1fca6fa21 --- /dev/null +++ b/src/api/defipulse.js @@ -0,0 +1,8 @@ +import { handler as lambda } from "../lambda/defipulse" + +async function handler(__req, res) { + const { statusCode, body } = await lambda() + res.status(statusCode).send(body) +} + +export default handler diff --git a/src/api/etherscan.js b/src/api/etherscan.js new file mode 100644 index 00000000000..de6f2628f83 --- /dev/null +++ b/src/api/etherscan.js @@ -0,0 +1,8 @@ +import { handler as lambda } from "../lambda/etherscan" + +async function handler(__req, res) { + const { statusCode, body } = await lambda() + res.status(statusCode).send(body) +} + +export default handler diff --git a/src/api/etherscanBlock.js b/src/api/etherscanBlock.js new file mode 100644 index 00000000000..907ab214dbe --- /dev/null +++ b/src/api/etherscanBlock.js @@ -0,0 +1,8 @@ +import { handler as lambda } from "../lambda/etherscanBlock" + +async function handler(__req, res) { + const { statusCode, body } = await lambda() + res.status(statusCode).send(body) +} + +export default handler diff --git a/src/api/roadmap.js b/src/api/roadmap.js new file mode 100644 index 00000000000..e16a9a32af0 --- /dev/null +++ b/src/api/roadmap.js @@ -0,0 +1,8 @@ +import { handler as lambda } from "../lambda/roadmap" + +async function handler(__req, res) { + const { statusCode, body } = await lambda() + res.status(statusCode).send(body) +} + +export default handler diff --git a/src/api/translations.js b/src/api/translations.js new file mode 100644 index 00000000000..64df6a81ce8 --- /dev/null +++ b/src/api/translations.js @@ -0,0 +1,8 @@ +import { handler as lambda } from "../lambda/translations" + +async function handler(__req, res) { + const { statusCode, body } = await lambda() + res.status(statusCode).send(body) +} + +export default handler diff --git a/src/api/txs.js b/src/api/txs.js new file mode 100644 index 00000000000..86d836e08eb --- /dev/null +++ b/src/api/txs.js @@ -0,0 +1,8 @@ +import { handler as lambda } from "../lambda/txs" + +async function handler(__req, res) { + const { statusCode, body } = await lambda() + res.status(statusCode).send(body) +} + +export default handler diff --git a/src/components/ReleaseBanner.js b/src/components/ReleaseBanner.js index 20e65e4ec6b..760da550d3e 100644 --- a/src/components/ReleaseBanner.js +++ b/src/components/ReleaseBanner.js @@ -56,7 +56,7 @@ const ReleaseBanner = ({ storageKey }) => { try { const data = await getFreshData( process.env.NODE_ENV === "production" - ? "/.netlify/functions/etherscanBlock" + ? `${process.env.GATSBY_FUNCTIONS_PATH}/etherscanBlock` : "http://localhost:9000/etherscanBlock" ) setTimeLeft(data) diff --git a/src/components/Roadmap.js b/src/components/Roadmap.js index 61af218474c..280a2d57e05 100644 --- a/src/components/Roadmap.js +++ b/src/components/Roadmap.js @@ -69,7 +69,7 @@ const Roadmap = () => { axios .get( process.env.NODE_ENV === "production" - ? "/.netlify/functions/roadmap" + ? `${process.env.GATSBY_FUNCTIONS_PATH}/roadmap` : "http://localhost:9000/roadmap" ) .then((response) => { diff --git a/src/components/StatsBoxGrid.js b/src/components/StatsBoxGrid.js index 0e8944167bd..046018bb402 100644 --- a/src/components/StatsBoxGrid.js +++ b/src/components/StatsBoxGrid.js @@ -339,7 +339,7 @@ const StatsBoxGrid = () => { try { const { result } = await getData( process.env.NODE_ENV === "production" - ? "/.netlify/functions/etherscan" + ? `${process.env.GATSBY_FUNCTIONS_PATH}/etherscan` : "http://localhost:9000/etherscan" ) const data = result @@ -368,7 +368,7 @@ const StatsBoxGrid = () => { try { const response = await getData( process.env.NODE_ENV === "production" - ? "/.netlify/functions/defipulse" + ? `${process.env.GATSBY_FUNCTIONS_PATH}/defipulse` : "http://localhost:9000/defipulse" ) const data = response @@ -397,7 +397,7 @@ const StatsBoxGrid = () => { try { const response = await getData( process.env.NODE_ENV === "production" - ? "/.netlify/functions/txs" + ? `${process.env.GATSBY_FUNCTIONS_PATH}/txs` : "http://localhost:9000/txs" ) const data = response.result diff --git a/src/components/TranslationsInProgress.js b/src/components/TranslationsInProgress.js index 591df5a219f..ae38a38d3be 100644 --- a/src/components/TranslationsInProgress.js +++ b/src/components/TranslationsInProgress.js @@ -21,7 +21,7 @@ const TranslationsInProgress = () => { axios .get( process.env.NODE_ENV === "production" - ? "/.netlify/functions/translations" + ? `${process.env.GATSBY_FUNCTIONS_PATH}/translations` : "http://localhost:9000/translations" ) .then((response) => {