Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Gatsby functions in preview deploys #5203

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions src/api/coinmetrics.js
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions src/api/defipulse.js
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions src/api/etherscan.js
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions src/api/etherscanBlock.js
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions src/api/roadmap.js
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions src/api/translations.js
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions src/api/txs.js
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/components/ReleaseBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Roadmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/StatsBoxGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/components/TranslationsInProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down