From 2510cfca52ef1002e798dbd74cc2f9a7152b3146 Mon Sep 17 00:00:00 2001 From: Jeroen Offerijns Date: Tue, 25 Jun 2024 14:17:08 +0200 Subject: [PATCH 1/9] Remove crowdloan page --- README.md | 11 -- data/crowdloan/altair.json | 64 ------------ data/crowdloan/parachain.json | 69 ------------- functions/src/createProof.ts | 38 ------- functions/src/getRewardData.ts | 28 ----- gatsby-node.ts | 15 +-- src/components/StatsCrowdloan.tsx | 60 ----------- src/components/crowdloan-user/User.tsx | 130 ------------------------ src/components/crowdloan-user/index.tsx | 27 ----- src/components/crowdloan-user/utils.tsx | 101 ------------------ src/components/hero-crowdloan/index.tsx | 56 ---------- src/templates/crowdloan.tsx | 74 -------------- 12 files changed, 4 insertions(+), 669 deletions(-) delete mode 100644 data/crowdloan/altair.json delete mode 100644 data/crowdloan/parachain.json delete mode 100644 functions/src/createProof.ts delete mode 100644 functions/src/getRewardData.ts delete mode 100644 src/components/StatsCrowdloan.tsx delete mode 100644 src/components/crowdloan-user/User.tsx delete mode 100644 src/components/crowdloan-user/index.tsx delete mode 100644 src/components/crowdloan-user/utils.tsx delete mode 100644 src/components/hero-crowdloan/index.tsx delete mode 100644 src/templates/crowdloan.tsx diff --git a/README.md b/README.md index 7f97f7f6..ed17ca17 100644 --- a/README.md +++ b/README.md @@ -74,17 +74,6 @@ are generated in `gatsby-node.ts`. The pages text content is stored in markdown --- -## Crowdloan Pages - -Both crowdloan pages - -- `/parachain/crowdloan` -- `/altair/crowdloan` - -are generated in `gatsby-node.ts`. Most of their content is static because the auctions are closed already. The routes are taken over from the former site to keep urls alive. - ---- - ## GraphQL Fragments Queries of component data are defined inside the component file. To be able to spread them into the page query, they are exported as fragments. diff --git a/data/crowdloan/altair.json b/data/crowdloan/altair.json deleted file mode 100644 index 1765d407..00000000 --- a/data/crowdloan/altair.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "slug": "/altair", - "seo": { - "title": "Altair Wins 9th Slot in Kusama Auctions | Centrifuge" - }, - "network": "altair", - "hero_crowdloan": { - "title": "Altair Wins 9th Slot in Kusama Auctions", - "amount": "187.84K KSM", - "contributors": "18,342" - }, - "stats": [ - { - "title": "Top referrers", - "items": [ - { - "address": "Fc2rXRok…Gu", - "amount": "641" - }, - { - "address": "CxZXGR8q…2v", - "amount": "570" - }, - { - "address": "EoqDfBE7…tF", - "amount": "367" - }, - { - "address": "DVSTJwhk…gu", - "amount": "354" - }, - { - "address": "G4SrBW47…ac", - "amount": "153" - } - ] - }, - { - "title": "Top contributors", - "items": [ - { - "address": "HNf7Bz3Q…ic", - "amount": "25,000 KSM" - }, - { - "address": "DDTVgKoS…c1", - "amount": "11,000 KSM" - }, - { - "address": "FFis2qYe…yr", - "amount": "7,000 KSM" - }, - { - "address": "J6bvL3mh…ZW", - "amount": "5,000 KSM" - }, - { - "address": "EkTrycMC…Ck", - "amount": "3,000 KSM" - } - ] - } - ] -} diff --git a/data/crowdloan/parachain.json b/data/crowdloan/parachain.json deleted file mode 100644 index 48dc3b22..00000000 --- a/data/crowdloan/parachain.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "slug": "/parachain", - "seo": { - "title": "Centrifuge Parachain Crowdloan | Centrifuge" - }, - "network": "centrifuge", - "hero_crowdloan": { - "title": "Boom! Centrifuge wins slot in Parachain auctions", - "body": "5,435,161 DOT raised from 27,101 contributions", - "amount": "5,435,161 DOT", - "contributors": "27,101", - "anchor": { - "label": "Learn more on parachains.info", - "href": "https://parachains.info/" - } - }, - "stats": [ - { - "title": "Top referrers", - "items": [ - { - "address": "14b8az…nLA9MJ", - "amount": "4485" - }, - { - "address": "12xiw7…5grrgU", - "amount": "3753" - }, - { - "address": "13Mf6q…QLJrm1", - "amount": "671" - }, - { - "address": "16DgBy…BZijXd", - "amount": "597" - }, - { - "address": "1PF1HL…MB5Mt1", - "amount": "565" - } - ] - }, - { - "title": "Top contributors", - "items": [ - { - "address": "12KjzR…JX3pMF", - "amount": "1,008,505 DOT" - }, - { - "address": "17QnZ6…cheWxx", - "amount": "549,970 DOT" - }, - { - "address": "12KweL…2a991h", - "amount": "350,000 DOT" - }, - { - "address": "162nEB…eao8cG", - "amount": "171,240 DOT" - }, - { - "address": "13gQM3…WgMFrH", - "amount": "100,007 DOT" - } - ] - } - ] -} diff --git a/functions/src/createProof.ts b/functions/src/createProof.ts deleted file mode 100644 index bc1e200f..00000000 --- a/functions/src/createProof.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Request, Response } from 'express' -import { createProof as createActualProof, getContributionAmount } from './handleCreateProof' -const { u8aToHex } = require('@polkadot/util') -const { decodeAddress } = require('@polkadot/util-crypto') -const JSONbig = require('json-bigint')({ - useNativeBigInt: true, - alwaysParseAsBig: true, -}) - -export default async function createProof(req: Request, res: Response) { - if (req.method !== 'POST') { - return res.status(405).send('Method not allowed. Use POST.') - } - - try { - const { address, parachain } = JSON.parse(req.body) - - const merkleTree = - parachain === 'centrifuge' - ? require('../../config/crowdloan/centrifuge-reward-merkle-tree.js').merkleTree - : require('../../config/crowdloan/altair-reward-merkle-tree.js').merkleTree - - const hexAddress = u8aToHex(decodeAddress(address)) - - const proof = createActualProof(hexAddress, merkleTree) - const contribution = getContributionAmount(hexAddress, merkleTree) - - return res.status(200).send( - JSONbig.stringify({ - proof, - signMessage: hexAddress, - contribution, - }) - ) - } catch (error) { - return res.status(500).send(JSON.stringify(error)) - } -} diff --git a/functions/src/getRewardData.ts b/functions/src/getRewardData.ts deleted file mode 100644 index 8b144173..00000000 --- a/functions/src/getRewardData.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { u8aToHex } from '@polkadot/util' -import { decodeAddress } from '@polkadot/util-crypto' -import { Request, Response } from 'express' -import { getContributionAmount } from './handleCreateProof' - -export default async function getRewardData(req: Request, res: Response) { - if (req.method !== 'POST') { - return res.status(405).send('Method not allowed. Use POST.') - } - - const { address, parachain } = JSON.parse(req.body) - - const merkleTree = - parachain === 'centrifuge' - ? require('../../config/crowdloan/centrifuge-reward-merkle-tree.js').merkleTree - : require('../../config/crowdloan/altair-reward-merkle-tree.js').merkleTree - - const hexAddress = u8aToHex(decodeAddress(address)) - - const amount = getContributionAmount(hexAddress, merkleTree) - - return res.status(200).send( - JSON.stringify({ - address, - contributionAmount: String(amount), - }) - ) -} diff --git a/gatsby-node.ts b/gatsby-node.ts index b5e4e40f..8c0d700e 100644 --- a/gatsby-node.ts +++ b/gatsby-node.ts @@ -1,7 +1,7 @@ import type { GatsbyNode } from 'gatsby' import path from 'path' -export const createPages: GatsbyNode['createPages'] = async ({ actions: { createPage } }) => { +export const createPages: GatsbyNode['createPages'] = async ({ actions: { createPage, createRedirect } }) => { try { const legalPages = ['/imprint', '/terms', '/security', '/data-privacy-policy'] @@ -15,16 +15,9 @@ export const createPages: GatsbyNode['createPages'] = async ({ actions: { create }) }) - const crowdloanPages = ['/altair', '/parachain'] - - crowdloanPages.forEach((route) => { - createPage({ - path: `${route}/crowdloan`, - component: path.resolve('./src/templates/crowdloan.tsx'), - context: { - slug: route, - }, - }) + createRedirect({ + fromPath: `/parachain/crowdloan`, + toPath: `/`, }) } catch (err) { console.log('error', err) diff --git a/src/components/StatsCrowdloan.tsx b/src/components/StatsCrowdloan.tsx deleted file mode 100644 index effdf221..00000000 --- a/src/components/StatsCrowdloan.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { Grid, Shelf, Box, Container, Text, Stack } from '@centrifuge/fabric' -import React from 'react' -import { graphql } from 'gatsby' - -export const query = graphql` - fragment StatsCrowdloanFragment on CrowdloanJsonStats { - title - items { - address - amount - } - } -` - -export type StatsCrowdloanProps = { - stats: { - title: string - items: { - address: string - amount: string - }[] - }[] -} - -export function StatsCrowdloan({ stats }: StatsCrowdloanProps) { - return ( - - - {stats.map((entry) => ( - - - {entry.title} - - - - {entry.items.map(({ address, amount }, index) => ( - - - {address} - - - {amount} - - - ))} - - - ))} - - - ) -} diff --git a/src/components/crowdloan-user/User.tsx b/src/components/crowdloan-user/User.tsx deleted file mode 100644 index a5a702fc..00000000 --- a/src/components/crowdloan-user/User.tsx +++ /dev/null @@ -1,130 +0,0 @@ -import { - formatBalanceAbbreviated, - useCentrifuge, - useCentrifugeTransaction, - useWallet, - WalletMenu, -} from '@centrifuge/centrifuge-react' -import { Button, Container, Shelf, Stack, Text } from '@centrifuge/fabric' -import { decodeAddress, signatureVerify } from '@polkadot/util-crypto' -import type { WalletAccount } from '@subwallet/wallet-connect/types' -import BN from 'bn.js' -import * as React from 'react' -import { switchMap } from 'rxjs' -import { getAccountDetails, useDidClaim, useTotalRewards } from './utils' - -export function User() { - const [isClaiming, setIsClaiming] = React.useState(false) - const centrifuge = useCentrifuge() - const { - substrate: { selectedAccount }, - } = useWallet() - const didClaim = useDidClaim(selectedAccount?.address) - const totalRewards = useTotalRewards({ address: selectedAccount?.address, parachain: centrifuge.config.network }) - const currency = centrifuge.config.network === 'altair' ? 'AIR' : 'CFG' - - const { execute, isLoading } = useCentrifugeTransaction( - 'Claiming rewards', - (cent) => - ([proof, signature, address]: [any, string, string], options) => { - return cent.getApi().pipe( - switchMap((api) => { - const verification = signatureVerify(proof.signMessage, signature, decodeAddress(address)) - if (!['sr25519', 'ed25519', 'ecdsa'].includes(verification.crypto)) { - throw new Error('Verification of signature failed with given account.') - } - - const submittable = api.tx.crowdloanClaim.claimReward( - address, - address, - { - [verification.crypto]: signature, - }, - { - leafHash: proof.proof.leafHash, - sortedHashes: proof.proof.sortedHashes, - }, - proof.contribution - ) - - return cent.wrapSignAndSend(api, submittable, options) - }) - ) - } - ) - - async function claim(account: WalletAccount | null) { - if (!account) { - return - } - - setIsClaiming(true) - - await getAccountDetails(account, centrifuge.config.network) - .then((response) => { - if (response) { - execute(response) - } - }) - .catch((error) => console.log(error)) - .finally(() => { - setIsClaiming(false) - }) - } - - return ( - - - - - {didClaim != null && - (didClaim ? ( - - - Rewards already claimed - - - ) : ( - - - Total rewards:{' '} - {totalRewards ? ( - - {formatBalanceAbbreviated(totalRewards, currency)} - - ) : ( - - 0.0 - - )} - - {!!totalRewards && totalRewards?.gt(new BN(0)) && ( - - )} - - ))} - - - Learn how to claim - - - - ) -} diff --git a/src/components/crowdloan-user/index.tsx b/src/components/crowdloan-user/index.tsx deleted file mode 100644 index 764fd15c..00000000 --- a/src/components/crowdloan-user/index.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { UserProvidedConfig } from '@centrifuge/centrifuge-js' -import { Provider } from '@centrifuge/centrifuge-react' -import * as React from 'react' -import { User } from './User' - -export type CrowdloanUserProps = { - network: 'altair' | 'centrifuge' -} - -export default function CrowdloanUser({ network }: CrowdloanUserProps) { - const centConfig: UserProvidedConfig = React.useMemo( - () => ({ - network, - ...(process.env.NODE_ENV === 'development' && { - centrifugeWsUrl: 'wss://fullnode.development.cntrfg.com', - altairWsUrl: 'wss://fullnode.development.cntrfg.com', - }), - }), - [] - ) - - return ( - - - - ) -} diff --git a/src/components/crowdloan-user/utils.tsx b/src/components/crowdloan-user/utils.tsx deleted file mode 100644 index 59afca06..00000000 --- a/src/components/crowdloan-user/utils.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import { CurrencyBalance } from '@centrifuge/centrifuge-js' -import { useCentrifugeQuery } from '@centrifuge/centrifuge-react' -import { cryptoWaitReady } from '@polkadot/util-crypto' -import type { WalletAccount } from '@subwallet/wallet-connect/types' -import jsonBigInt from 'json-bigint' -import { useQuery } from 'react-query' -import { map, switchMap } from 'rxjs' -import type { CrowdloanUserProps } from './index' - -const JsonBig = jsonBigInt({ useNativeBigInt: true, alwaysParseAsBig: true }) - -export function useTotalRewards({ - address, - parachain, -}: { - address?: WalletAccount['address'] - parachain: CrowdloanUserProps['network'] -}) { - const { data } = useQuery( - ['getRewardData', address, parachain], - async () => { - const response = await fetch(`${process.env.GATSBY_FUNCTIONS_URL}/getRewardData`, { - method: 'POST', - body: JSON.stringify({ - address, - parachain, - }), - }) - - const json = await response.json() - const amount = new CurrencyBalance(json.contributionAmount, 18) - return amount - }, - { - enabled: !!address, - } - ) - - return data -} - -export function useDidClaim(address?: string) { - const [data] = useCentrifugeQuery( - ['claimedRewards', address], - (cent) => { - return cent.getApi().pipe( - switchMap((api) => { - return api.query.crowdloanClaim.processedClaims([address, 1]) - }), - map((didClaim) => { - return didClaim.toHuman() ? true : false - }) - ) - }, - { - enabled: !!address, - } - ) - return data -} - -export async function getAccountDetails( - account: WalletAccount, - parachain: CrowdloanUserProps['network'] -): Promise<[any, string, string] | null> { - if (!account) { - return null - } - - const proof = await fetch(`${process.env.GATSBY_FUNCTIONS_URL}/createProof`, { - method: 'POST', - body: JSON.stringify({ address: account.address, parachain }), - }) - .then(async (response) => { - if (!response.ok) { - throw new Error('Could not create proof') - } - - return await response.text() - }) - .then((text) => JsonBig.parse(text)) - .catch((error) => console.log(error)) - - const signature = await cryptoWaitReady() - .then((_) => account.wallet?.signer?.signRaw) - .then(async (signRaw) => { - if (!signRaw) { - throw new Error('signRaw was not defined') - } - - return await signRaw({ - address: account.address, - data: proof.signMessage, - type: 'bytes', - }) - }) - .then((payload) => payload.signature) - .catch((error) => console.log(error)) - - return [proof, signature as string, account.address] -} diff --git a/src/components/hero-crowdloan/index.tsx b/src/components/hero-crowdloan/index.tsx deleted file mode 100644 index 1521415f..00000000 --- a/src/components/hero-crowdloan/index.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import React from 'react' -import { graphql } from 'gatsby' -import { Container, Box, Text, AnchorButton } from '@centrifuge/fabric' - -export const query = graphql` - fragment HeroCrowdloanFragment on CrowdloanJsonHero_crowdloan { - title - amount - contributors - anchor { - label - href - } - } -` - -export type HeroCrowdloanProps = { - title: string - amount: string - contributors: string - anchor?: { - label: string - href: string - } -} - -export function HeroCrowdloan({ title, amount, contributors, anchor }: HeroCrowdloanProps) { - return ( - - - Crowdloan - - - {title} - - - {amount} raised from {contributors} contributions - - {anchor && ( - - - {anchor.label} - - - )} - - ) -} - -function Em({ children }: { children: React.ReactNode }) { - return ( - - {children} - - ) -} diff --git a/src/templates/crowdloan.tsx b/src/templates/crowdloan.tsx deleted file mode 100644 index b3aab9fd..00000000 --- a/src/templates/crowdloan.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import * as React from 'react' -import { Box, Stack, Text } from '@centrifuge/fabric' -import type { HeadProps } from 'gatsby' -import { graphql } from 'gatsby' -import type { CrowdloanUserProps } from '../components/crowdloan-user' -import type { HeroCrowdloanProps } from '../components/hero-crowdloan' -import { HeroCrowdloan } from '../components/hero-crowdloan' -import { Layout } from '../components/Layout' -import type { SEOProps } from '../components/Seo' -import { SEO } from '../components/Seo' -import type { StatsCrowdloanProps } from '../components/StatsCrowdloan' -import { StatsCrowdloan } from '../components/StatsCrowdloan' - -const CrowdloanUser = React.lazy(() => import('../components/crowdloan-user')) - -export const query = graphql` - query ($slug: String!) { - crowdloanJson(slug: { eq: $slug }) { - seo { - title - } - - network - - hero_crowdloan { - ...HeroCrowdloanFragment - } - - stats { - ...StatsCrowdloanFragment - } - } - } -` - -type CrowdloanPageProps = { - data: { - crowdloanJson: { - seo: SEOProps - network: CrowdloanUserProps['network'] - hero_crowdloan: HeroCrowdloanProps - stats: StatsCrowdloanProps['stats'] - } - } -} - -export default function CrowdloanPage({ data }: CrowdloanPageProps) { - const [isRendered, setIsRendered] = React.useState(false) - const { hero_crowdloan, stats, network } = data.crowdloanJson - - React.useEffect(() => setIsRendered(true), []) - - return ( - - - - Auction ended — Closed for contribution - - - - - {isRendered ? : null} - - - - ) -} - -export const Head = ({ data, location }: CrowdloanPageProps & HeadProps) => { - const { seo } = data.crowdloanJson - const { pathname } = location - - return -} From d3dcbf02a7591a10991e817e67640849dc8b214b Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Tue, 25 Jun 2024 15:27:12 +0200 Subject: [PATCH 2/9] remove functions from esbuild --- functions/esbuild.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/esbuild.js b/functions/esbuild.js index 15d4f085..425ee051 100644 --- a/functions/esbuild.js +++ b/functions/esbuild.js @@ -13,8 +13,6 @@ esbuild 'functions/index.ts', 'functions/src/getExample.ts', 'functions/src/getLeverPositions.ts', - 'functions/src/createProof.ts', - 'functions/src/getRewardData.ts', 'functions/src/getPoolsData.ts', 'functions/src/getTotalAssetsTokenized.ts', ], From ed880aa4a3a8ab4d6812b73888c0d2528ae10526 Mon Sep 17 00:00:00 2001 From: Jeroen Offerijns Date: Wed, 26 Jun 2024 10:22:08 +0200 Subject: [PATCH 3/9] Add redirects plugin for cloudflare pages --- gatsby-config.ts | 1 + package.json | 1 + yarn.lock | 117 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 115 insertions(+), 4 deletions(-) diff --git a/gatsby-config.ts b/gatsby-config.ts index 809332ef..3a351ca6 100644 --- a/gatsby-config.ts +++ b/gatsby-config.ts @@ -15,6 +15,7 @@ const config: GatsbyConfig = { graphqlTypegen: true, plugins: [ 'gatsby-plugin-styled-components', + 'gatsby-plugin-cloudflare-pages', { resolve: 'gatsby-source-filesystem', options: { diff --git a/package.json b/package.json index f518d433..5e4e8e77 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "embla-carousel-react": "^7.0.3", "focus-trap-react": "^10.0.0", "gatsby": "^4.23.1", + "gatsby-plugin-cloudflare-pages": "^1.0.3", "gatsby-plugin-google-gtag": "^4.24.0", "gatsby-plugin-image": "^2.24.0", "gatsby-plugin-mailchimp": "^5.2.2", diff --git a/yarn.lock b/yarn.lock index 8275d762..0d52259d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1095,6 +1095,13 @@ dependencies: regenerator-runtime "^0.14.0" +"@babel/runtime@^7.20.13", "@babel/runtime@^7.24.1": + version "7.24.7" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.7.tgz#f4f0d5530e8dbdf59b3451b9b3e594b6ba082e12" + integrity sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw== + dependencies: + regenerator-runtime "^0.14.0" + "@babel/template@^7.16.7", "@babel/template@^7.22.15", "@babel/template@^7.22.5": version "7.22.15" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.15.tgz#09576efc3830f0430f4548ef971dde1350ef2f38" @@ -6570,7 +6577,7 @@ deep-is@^0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== -deepmerge@^4.2.2: +deepmerge@^4.2.2, deepmerge@^4.3.1: version "4.3.1" resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== @@ -7860,6 +7867,13 @@ fastq@^1.13.0, fastq@^1.6.0: dependencies: reusify "^1.0.4" +fastq@^1.15.0: + version "1.17.1" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.17.1.tgz#2a523f07a4e7b1e81a42b91b8bf2254107753b47" + integrity sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w== + dependencies: + reusify "^1.0.4" + fb-watchman@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c" @@ -8120,6 +8134,15 @@ fs-extra@^10.1.0: jsonfile "^6.0.1" universalify "^2.0.0" +fs-extra@^11.1.1, fs-extra@^11.2.0: + version "11.2.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b" + integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs-extra@^9.0.0: version "9.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" @@ -8239,6 +8262,28 @@ gatsby-core-utils@^3.25.0: tmp "^0.2.1" xdg-basedir "^4.0.0" +gatsby-core-utils@^4.13.1: + version "4.13.1" + resolved "https://registry.yarnpkg.com/gatsby-core-utils/-/gatsby-core-utils-4.13.1.tgz#57955316486cc85ab150922f481484bc9287205e" + integrity sha512-w7G6SsQr8T2q+AJ1MxvRNGocCt+wjc22MiRLj2Zi3Ijpjszbr818JxwI4+aPt8WOSHlKT5SYCHICnEvcYPm9gg== + dependencies: + "@babel/runtime" "^7.20.13" + ci-info "2.0.0" + configstore "^5.0.1" + fastq "^1.15.0" + file-type "^16.5.4" + fs-extra "^11.1.1" + got "^11.8.6" + hash-wasm "^4.9.0" + import-from "^4.0.0" + lmdb "2.5.3" + lock "^1.1.0" + node-object-hash "^2.3.10" + proper-lockfile "^4.1.2" + resolve-from "^5.0.0" + tmp "^0.2.1" + xdg-basedir "^4.0.0" + gatsby-graphiql-explorer@^2.25.0: version "2.25.0" resolved "https://registry.yarnpkg.com/gatsby-graphiql-explorer/-/gatsby-graphiql-explorer-2.25.0.tgz#78fe692009739cbd330b6c10a1cfebcff8301ab8" @@ -8295,6 +8340,18 @@ gatsby-parcel-config@0.16.0: "@parcel/transformer-js" "2.6.2" "@parcel/transformer-json" "2.6.2" +gatsby-plugin-cloudflare-pages@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/gatsby-plugin-cloudflare-pages/-/gatsby-plugin-cloudflare-pages-1.0.3.tgz#2461d8cf689a507f5993f0e67b2a2bf40aa1f3d5" + integrity sha512-jDyyB7kG+mEW0SbeM+w51y05q8s78NBCW2VthiMLSlKbflyJ2obHQPPWz4gLrpsqwoo18ZgIV14GLIgGuXqohQ== + dependencies: + "@babel/runtime" "^7.24.1" + fs-extra "^11.2.0" + gatsby-core-utils "^4.13.1" + kebab-hash "^0.1.2" + lodash.mergewith "^4.6.2" + webpack-assets-manifest "^5.2.1" + gatsby-plugin-google-gtag@^4.24.0: version "4.25.0" resolved "https://registry.yarnpkg.com/gatsby-plugin-google-gtag/-/gatsby-plugin-google-gtag-4.25.0.tgz#cfea9ab34cb9c053440757e76f2863f2aad310bf" @@ -8843,7 +8900,7 @@ gopd@^1.0.1: dependencies: get-intrinsic "^1.1.3" -got@^11.8.5: +got@^11.8.5, got@^11.8.6: version "11.8.6" resolved "https://registry.yarnpkg.com/got/-/got-11.8.6.tgz#276e827ead8772eddbcfc97170590b841823233a" integrity sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g== @@ -8988,6 +9045,11 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" +hash-wasm@^4.9.0: + version "4.11.0" + resolved "https://registry.yarnpkg.com/hash-wasm/-/hash-wasm-4.11.0.tgz#7d1479b114c82e48498fdb1d2462a687d00386d5" + integrity sha512-HVusNXlVqHe0fzIzdQOGolnFN6mX/fqcrSAOcTBXdvzrXVHwTz11vXeKRmkR5gTuwVpvHZEIyKoePDvuAR+XwQ== + hash.js@1.1.7, hash.js@^1.0.0, hash.js@^1.0.3: version "1.1.7" resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" @@ -10047,6 +10109,13 @@ jw3t@^1.0.8: "@polkadot/util-crypto" "^11.1.1" js-base64 "^3.7.5" +kebab-hash@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/kebab-hash/-/kebab-hash-0.1.2.tgz#dfb7949ba34d8e70114ea7d83e266e5e2a4abaac" + integrity sha512-BTZpq3xgISmQmAVzkISy4eUutsUA7s4IEFlCwOBJjvSFOwyR7I+fza+tBc/rzYWK/NrmFHjfU1IhO3lu29Ib/w== + dependencies: + lodash.kebabcase "^4.1.1" + keccak@^3.0.1: version "3.0.4" resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.4.tgz#edc09b89e633c0549da444432ecf062ffadee86d" @@ -10256,6 +10325,13 @@ lock@^1.1.0: resolved "https://registry.yarnpkg.com/lock/-/lock-1.1.0.tgz#53157499d1653b136ca66451071fca615703fa55" integrity sha512-NZQIJJL5Rb9lMJ0Yl1JoVr9GSdo4HTPsUEWsSFzB8dE8DSoiLCVavWZPi7Rnlv/o73u6I24S/XYc/NmG4l8EKA== +lockfile@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/lockfile/-/lockfile-1.0.4.tgz#07f819d25ae48f87e538e6578b6964a4981a5609" + integrity sha512-cvbTwETRfsFh4nHsL1eGWapU1XFi5Ot9E85sWAwia7Y7EgB7vfqcZhTKZ+l7hCGxSPoushMv5GKhT5PdLv03WA== + dependencies: + signal-exit "^3.0.2" + lodash.clonedeep@4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" @@ -10286,11 +10362,26 @@ lodash.foreach@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" integrity sha512-aEXTF4d+m05rVOAUG3z4vZZ4xVexLKZGF0lIxuHZ1Hplpk/3B6Z1+/ICICYRLm7c41Z2xiejbkCkJoTlypoXhQ== +lodash.get@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" + integrity sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ== + +lodash.has@^4.5.2: + version "4.5.2" + resolved "https://registry.yarnpkg.com/lodash.has/-/lodash.has-4.5.2.tgz#d19f4dc1095058cccbe2b0cdf4ee0fe4aa37c862" + integrity sha512-rnYUdIo6xRCJnQmbVFEwcxF144erlD+M3YcJUVesflU9paQaE8p+fJDcIQrlMYbxoANFL+AB9hZrzSBBk5PL+g== + lodash.isequal@4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" integrity sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ== +lodash.kebabcase@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36" + integrity sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g== + lodash.map@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" @@ -10311,6 +10402,11 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== +lodash.mergewith@^4.6.2: + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz#617121f89ac55f59047c7aec1ccd6654c6590f55" + integrity sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ== + lodash.truncate@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" @@ -13159,7 +13255,7 @@ schema-utils@^2.6.5: ajv "^6.12.4" ajv-keywords "^3.5.2" -schema-utils@^3.0.0, schema-utils@^3.1.1, schema-utils@^3.2.0: +schema-utils@^3.0.0, schema-utils@^3.1.1, schema-utils@^3.2.0, schema-utils@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.3.0.tgz#f50a88877c3c01652a15b622ae9e9795df7a60fe" integrity sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg== @@ -13959,7 +14055,7 @@ tapable@^1.0.0: resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2" integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== -tapable@^2.1.1, tapable@^2.2.0: +tapable@^2.1.1, tapable@^2.2.0, tapable@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== @@ -14781,6 +14877,19 @@ webidl-conversions@^3.0.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== +webpack-assets-manifest@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/webpack-assets-manifest/-/webpack-assets-manifest-5.2.1.tgz#7ebe4c882efdc343029ed2f54a6f7ce990406f08" + integrity sha512-MsEcXVio1GY6R+b4dVfTHIDMB0RB90KajQG8neRbH92vE2S1ClGw9mNa9NPlratYBvZOhExmN0qqMNFTaCTuIg== + dependencies: + chalk "^4.1.2" + deepmerge "^4.3.1" + lockfile "^1.0.4" + lodash.get "^4.4.2" + lodash.has "^4.5.2" + schema-utils "^3.3.0" + tapable "^2.2.1" + webpack-dev-middleware@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-4.3.0.tgz#179cc40795882cae510b1aa7f3710cbe93c9333e" From b15487444d1a449db5d91365a109af42fc08e570 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Wed, 26 Jun 2024 16:52:56 +0200 Subject: [PATCH 4/9] Revert "Add redirects plugin for cloudflare pages" This reverts commit ed880aa4a3a8ab4d6812b73888c0d2528ae10526. --- gatsby-config.ts | 1 - package.json | 1 - yarn.lock | 117 ++--------------------------------------------- 3 files changed, 4 insertions(+), 115 deletions(-) diff --git a/gatsby-config.ts b/gatsby-config.ts index 3a351ca6..809332ef 100644 --- a/gatsby-config.ts +++ b/gatsby-config.ts @@ -15,7 +15,6 @@ const config: GatsbyConfig = { graphqlTypegen: true, plugins: [ 'gatsby-plugin-styled-components', - 'gatsby-plugin-cloudflare-pages', { resolve: 'gatsby-source-filesystem', options: { diff --git a/package.json b/package.json index 5e4e8e77..f518d433 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "embla-carousel-react": "^7.0.3", "focus-trap-react": "^10.0.0", "gatsby": "^4.23.1", - "gatsby-plugin-cloudflare-pages": "^1.0.3", "gatsby-plugin-google-gtag": "^4.24.0", "gatsby-plugin-image": "^2.24.0", "gatsby-plugin-mailchimp": "^5.2.2", diff --git a/yarn.lock b/yarn.lock index 0d52259d..8275d762 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1095,13 +1095,6 @@ dependencies: regenerator-runtime "^0.14.0" -"@babel/runtime@^7.20.13", "@babel/runtime@^7.24.1": - version "7.24.7" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.7.tgz#f4f0d5530e8dbdf59b3451b9b3e594b6ba082e12" - integrity sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw== - dependencies: - regenerator-runtime "^0.14.0" - "@babel/template@^7.16.7", "@babel/template@^7.22.15", "@babel/template@^7.22.5": version "7.22.15" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.15.tgz#09576efc3830f0430f4548ef971dde1350ef2f38" @@ -6577,7 +6570,7 @@ deep-is@^0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== -deepmerge@^4.2.2, deepmerge@^4.3.1: +deepmerge@^4.2.2: version "4.3.1" resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== @@ -7867,13 +7860,6 @@ fastq@^1.13.0, fastq@^1.6.0: dependencies: reusify "^1.0.4" -fastq@^1.15.0: - version "1.17.1" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.17.1.tgz#2a523f07a4e7b1e81a42b91b8bf2254107753b47" - integrity sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w== - dependencies: - reusify "^1.0.4" - fb-watchman@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c" @@ -8134,15 +8120,6 @@ fs-extra@^10.1.0: jsonfile "^6.0.1" universalify "^2.0.0" -fs-extra@^11.1.1, fs-extra@^11.2.0: - version "11.2.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b" - integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^6.0.1" - universalify "^2.0.0" - fs-extra@^9.0.0: version "9.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" @@ -8262,28 +8239,6 @@ gatsby-core-utils@^3.25.0: tmp "^0.2.1" xdg-basedir "^4.0.0" -gatsby-core-utils@^4.13.1: - version "4.13.1" - resolved "https://registry.yarnpkg.com/gatsby-core-utils/-/gatsby-core-utils-4.13.1.tgz#57955316486cc85ab150922f481484bc9287205e" - integrity sha512-w7G6SsQr8T2q+AJ1MxvRNGocCt+wjc22MiRLj2Zi3Ijpjszbr818JxwI4+aPt8WOSHlKT5SYCHICnEvcYPm9gg== - dependencies: - "@babel/runtime" "^7.20.13" - ci-info "2.0.0" - configstore "^5.0.1" - fastq "^1.15.0" - file-type "^16.5.4" - fs-extra "^11.1.1" - got "^11.8.6" - hash-wasm "^4.9.0" - import-from "^4.0.0" - lmdb "2.5.3" - lock "^1.1.0" - node-object-hash "^2.3.10" - proper-lockfile "^4.1.2" - resolve-from "^5.0.0" - tmp "^0.2.1" - xdg-basedir "^4.0.0" - gatsby-graphiql-explorer@^2.25.0: version "2.25.0" resolved "https://registry.yarnpkg.com/gatsby-graphiql-explorer/-/gatsby-graphiql-explorer-2.25.0.tgz#78fe692009739cbd330b6c10a1cfebcff8301ab8" @@ -8340,18 +8295,6 @@ gatsby-parcel-config@0.16.0: "@parcel/transformer-js" "2.6.2" "@parcel/transformer-json" "2.6.2" -gatsby-plugin-cloudflare-pages@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/gatsby-plugin-cloudflare-pages/-/gatsby-plugin-cloudflare-pages-1.0.3.tgz#2461d8cf689a507f5993f0e67b2a2bf40aa1f3d5" - integrity sha512-jDyyB7kG+mEW0SbeM+w51y05q8s78NBCW2VthiMLSlKbflyJ2obHQPPWz4gLrpsqwoo18ZgIV14GLIgGuXqohQ== - dependencies: - "@babel/runtime" "^7.24.1" - fs-extra "^11.2.0" - gatsby-core-utils "^4.13.1" - kebab-hash "^0.1.2" - lodash.mergewith "^4.6.2" - webpack-assets-manifest "^5.2.1" - gatsby-plugin-google-gtag@^4.24.0: version "4.25.0" resolved "https://registry.yarnpkg.com/gatsby-plugin-google-gtag/-/gatsby-plugin-google-gtag-4.25.0.tgz#cfea9ab34cb9c053440757e76f2863f2aad310bf" @@ -8900,7 +8843,7 @@ gopd@^1.0.1: dependencies: get-intrinsic "^1.1.3" -got@^11.8.5, got@^11.8.6: +got@^11.8.5: version "11.8.6" resolved "https://registry.yarnpkg.com/got/-/got-11.8.6.tgz#276e827ead8772eddbcfc97170590b841823233a" integrity sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g== @@ -9045,11 +8988,6 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" -hash-wasm@^4.9.0: - version "4.11.0" - resolved "https://registry.yarnpkg.com/hash-wasm/-/hash-wasm-4.11.0.tgz#7d1479b114c82e48498fdb1d2462a687d00386d5" - integrity sha512-HVusNXlVqHe0fzIzdQOGolnFN6mX/fqcrSAOcTBXdvzrXVHwTz11vXeKRmkR5gTuwVpvHZEIyKoePDvuAR+XwQ== - hash.js@1.1.7, hash.js@^1.0.0, hash.js@^1.0.3: version "1.1.7" resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" @@ -10109,13 +10047,6 @@ jw3t@^1.0.8: "@polkadot/util-crypto" "^11.1.1" js-base64 "^3.7.5" -kebab-hash@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/kebab-hash/-/kebab-hash-0.1.2.tgz#dfb7949ba34d8e70114ea7d83e266e5e2a4abaac" - integrity sha512-BTZpq3xgISmQmAVzkISy4eUutsUA7s4IEFlCwOBJjvSFOwyR7I+fza+tBc/rzYWK/NrmFHjfU1IhO3lu29Ib/w== - dependencies: - lodash.kebabcase "^4.1.1" - keccak@^3.0.1: version "3.0.4" resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.4.tgz#edc09b89e633c0549da444432ecf062ffadee86d" @@ -10325,13 +10256,6 @@ lock@^1.1.0: resolved "https://registry.yarnpkg.com/lock/-/lock-1.1.0.tgz#53157499d1653b136ca66451071fca615703fa55" integrity sha512-NZQIJJL5Rb9lMJ0Yl1JoVr9GSdo4HTPsUEWsSFzB8dE8DSoiLCVavWZPi7Rnlv/o73u6I24S/XYc/NmG4l8EKA== -lockfile@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/lockfile/-/lockfile-1.0.4.tgz#07f819d25ae48f87e538e6578b6964a4981a5609" - integrity sha512-cvbTwETRfsFh4nHsL1eGWapU1XFi5Ot9E85sWAwia7Y7EgB7vfqcZhTKZ+l7hCGxSPoushMv5GKhT5PdLv03WA== - dependencies: - signal-exit "^3.0.2" - lodash.clonedeep@4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" @@ -10362,26 +10286,11 @@ lodash.foreach@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" integrity sha512-aEXTF4d+m05rVOAUG3z4vZZ4xVexLKZGF0lIxuHZ1Hplpk/3B6Z1+/ICICYRLm7c41Z2xiejbkCkJoTlypoXhQ== -lodash.get@^4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" - integrity sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ== - -lodash.has@^4.5.2: - version "4.5.2" - resolved "https://registry.yarnpkg.com/lodash.has/-/lodash.has-4.5.2.tgz#d19f4dc1095058cccbe2b0cdf4ee0fe4aa37c862" - integrity sha512-rnYUdIo6xRCJnQmbVFEwcxF144erlD+M3YcJUVesflU9paQaE8p+fJDcIQrlMYbxoANFL+AB9hZrzSBBk5PL+g== - lodash.isequal@4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" integrity sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ== -lodash.kebabcase@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36" - integrity sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g== - lodash.map@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" @@ -10402,11 +10311,6 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash.mergewith@^4.6.2: - version "4.6.2" - resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz#617121f89ac55f59047c7aec1ccd6654c6590f55" - integrity sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ== - lodash.truncate@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" @@ -13255,7 +13159,7 @@ schema-utils@^2.6.5: ajv "^6.12.4" ajv-keywords "^3.5.2" -schema-utils@^3.0.0, schema-utils@^3.1.1, schema-utils@^3.2.0, schema-utils@^3.3.0: +schema-utils@^3.0.0, schema-utils@^3.1.1, schema-utils@^3.2.0: version "3.3.0" resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.3.0.tgz#f50a88877c3c01652a15b622ae9e9795df7a60fe" integrity sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg== @@ -14055,7 +13959,7 @@ tapable@^1.0.0: resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2" integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== -tapable@^2.1.1, tapable@^2.2.0, tapable@^2.2.1: +tapable@^2.1.1, tapable@^2.2.0: version "2.2.1" resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== @@ -14877,19 +14781,6 @@ webidl-conversions@^3.0.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== -webpack-assets-manifest@^5.2.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/webpack-assets-manifest/-/webpack-assets-manifest-5.2.1.tgz#7ebe4c882efdc343029ed2f54a6f7ce990406f08" - integrity sha512-MsEcXVio1GY6R+b4dVfTHIDMB0RB90KajQG8neRbH92vE2S1ClGw9mNa9NPlratYBvZOhExmN0qqMNFTaCTuIg== - dependencies: - chalk "^4.1.2" - deepmerge "^4.3.1" - lockfile "^1.0.4" - lodash.get "^4.4.2" - lodash.has "^4.5.2" - schema-utils "^3.3.0" - tapable "^2.2.1" - webpack-dev-middleware@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-4.3.0.tgz#179cc40795882cae510b1aa7f3710cbe93c9333e" From b527719647366a3f705b2f1e7122a321c5fed859 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Wed, 26 Jun 2024 16:54:04 +0200 Subject: [PATCH 5/9] Add redirect to functions routing --- functions/routes.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions/routes.json b/functions/routes.json index b7dc08e6..f61c840d 100644 --- a/functions/routes.json +++ b/functions/routes.json @@ -17,5 +17,10 @@ { "name": "getExample", "options": {} + }, + { + "source": "/parachain/crowdloan", + "destination": "/", + "statusCode": 301 } ] From 1cc0e90033f2469b89e30b8070c8fd009f220656 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Wed, 26 Jun 2024 16:55:01 +0200 Subject: [PATCH 6/9] Add redirect to functions routing for altair too --- functions/routes.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/functions/routes.json b/functions/routes.json index f61c840d..9a03c596 100644 --- a/functions/routes.json +++ b/functions/routes.json @@ -22,5 +22,11 @@ "source": "/parachain/crowdloan", "destination": "/", "statusCode": 301 - } + }, + , + { + "source": "/altair/crowdloan", + "destination": "/", + "statusCode": 301 + } ] From 5b02d430854975289791ca35f9b9ef4bca461053 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Wed, 26 Jun 2024 17:10:25 +0200 Subject: [PATCH 7/9] remove extra comma --- functions/routes.json | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/routes.json b/functions/routes.json index 9a03c596..9000712d 100644 --- a/functions/routes.json +++ b/functions/routes.json @@ -23,7 +23,6 @@ "destination": "/", "statusCode": 301 }, - , { "source": "/altair/crowdloan", "destination": "/", From 793f869800ee4a0e618c2bb0847c87b874e121f0 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Wed, 26 Jun 2024 18:31:32 +0200 Subject: [PATCH 8/9] check redirects first thing --- functions/index.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/functions/index.ts b/functions/index.ts index e1f8885c..910d7d16 100644 --- a/functions/index.ts +++ b/functions/index.ts @@ -10,25 +10,27 @@ const corsWhitelist = [ const testEnvRegex = new RegExp('https://preview-pr[0-9]*(.k-f.dev)') exports.handler = async (req: Request, res: Response) => { - if (routes.length < 0) { - return res.status(400).send('No functions defined') + // Check for redirects first + const redirect = routes.find(route => route.source && req.path.endsWith(route.source)); + if (redirect) { + return res.redirect(redirect.statusCode, redirect.destination); } - const origin = req.get('origin') - + // Existing CORS and route handling + const origin = req.get('origin'); if (corsWhitelist.indexOf(origin) !== -1 || testEnvRegex.test(origin)) { - res.set('Access-Control-Allow-Origin', origin) - res.set('Access-Control-Allow-Methods', ['GET', 'POST']) + res.set('Access-Control-Allow-Origin', origin); + res.set('Access-Control-Allow-Methods', ['GET', 'POST']); } else { - return res.status(405).send('Not allowed') + return res.status(405).send('Not allowed'); } for (let route of routes) { - if (req.path.replace('/', '') === route.name) { - const method = require(`./src/${route.name}`) - - return method.default(req, res, route?.options ?? {}) + if (route.name && req.path.replace('/', '') === route.name) { + const method = require(`./src/${route.name}`); + return method.default(req, res, route?.options ?? {}); } } - return res.status(500).send('An error occured') + + return res.status(500).send('An error occurred'); } From ce985a9e6c4fab31b6994ad7cab1950a19ef83ca Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Wed, 26 Jun 2024 18:44:48 +0200 Subject: [PATCH 9/9] Remove redirections from the functions, handled by CF --- functions/index.ts | 26 ++++++++++++-------------- functions/routes.json | 12 +----------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/functions/index.ts b/functions/index.ts index 910d7d16..e1f8885c 100644 --- a/functions/index.ts +++ b/functions/index.ts @@ -10,27 +10,25 @@ const corsWhitelist = [ const testEnvRegex = new RegExp('https://preview-pr[0-9]*(.k-f.dev)') exports.handler = async (req: Request, res: Response) => { - // Check for redirects first - const redirect = routes.find(route => route.source && req.path.endsWith(route.source)); - if (redirect) { - return res.redirect(redirect.statusCode, redirect.destination); + if (routes.length < 0) { + return res.status(400).send('No functions defined') } - // Existing CORS and route handling - const origin = req.get('origin'); + const origin = req.get('origin') + if (corsWhitelist.indexOf(origin) !== -1 || testEnvRegex.test(origin)) { - res.set('Access-Control-Allow-Origin', origin); - res.set('Access-Control-Allow-Methods', ['GET', 'POST']); + res.set('Access-Control-Allow-Origin', origin) + res.set('Access-Control-Allow-Methods', ['GET', 'POST']) } else { - return res.status(405).send('Not allowed'); + return res.status(405).send('Not allowed') } for (let route of routes) { - if (route.name && req.path.replace('/', '') === route.name) { - const method = require(`./src/${route.name}`); - return method.default(req, res, route?.options ?? {}); + if (req.path.replace('/', '') === route.name) { + const method = require(`./src/${route.name}`) + + return method.default(req, res, route?.options ?? {}) } } - - return res.status(500).send('An error occurred'); + return res.status(500).send('An error occured') } diff --git a/functions/routes.json b/functions/routes.json index 9000712d..b7dc08e6 100644 --- a/functions/routes.json +++ b/functions/routes.json @@ -17,15 +17,5 @@ { "name": "getExample", "options": {} - }, - { - "source": "/parachain/crowdloan", - "destination": "/", - "statusCode": 301 - }, - { - "source": "/altair/crowdloan", - "destination": "/", - "statusCode": 301 - } + } ]