-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Import old trigger.dev revalidation tasks for backward compatibility #17034
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export { revalidate10YearAnniversary } from "./revalidate-10-year-anniversary" | ||
| export { revalidateAppsPages } from "./revalidate-apps" | ||
| export { revalidateFindWalletPage } from "./revalidate-find-wallet-page" | ||
| export { revalidateHomePage } from "./revalidate-home-page" | ||
| export { revalidateLayer2NetworksPage } from "./revalidate-layer-2-networks-page" | ||
| export { revalidateLayer2Page } from "./revalidate-layer-2-page" | ||
| export { revalidateStablecoinsPage } from "./revalidate-stablecoins-page" | ||
| export { revalidateStakingPage } from "./revalidate-staking-page" |
12 changes: 12 additions & 0 deletions
12
src/data-layer/trigger/old-tasks/revalidate-10-year-anniversary.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { schedules } from "@trigger.dev/sdk/v3" | ||
|
|
||
| import { revalidatePaths } from "./utils" | ||
|
|
||
| export const revalidate10YearAnniversary = schedules.task({ | ||
| id: "revalidate-10-year-anniversary", | ||
| // every day | ||
| cron: "0 0 * * *", | ||
| run: async () => { | ||
| await revalidatePaths(["/10-year-anniversary/"]) | ||
| }, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { schedules } from "@trigger.dev/sdk/v3" | ||
|
|
||
| import { slugify } from "@/lib/utils/url" | ||
|
|
||
| import { revalidatePaths } from "./utils" | ||
|
|
||
| import { fetchApps } from "@/lib/api/fetchApps" | ||
|
|
||
| const categoriesSlugs = [ | ||
| "defi", | ||
| "collectibles", | ||
| "social", | ||
| "gaming", | ||
| "bridge", | ||
| "productivity", | ||
| "privacy", | ||
| "dao", | ||
| ] | ||
|
|
||
| export const revalidateAppsPages = schedules.task({ | ||
| id: "revalidate-apps-pages", | ||
| // every day | ||
| cron: "0 0 * * *", | ||
| run: async () => { | ||
| // Generate dynamic paths | ||
| const paths = ["/apps", "/apps/"] | ||
|
|
||
| // Add category paths | ||
| categoriesSlugs.forEach((category) => { | ||
| paths.push(`/apps/categories/${category}`) | ||
| }) | ||
|
|
||
| // Fetch apps data and add individual app paths | ||
| try { | ||
| const appsData = await fetchApps() | ||
|
|
||
| Object.values(appsData) | ||
| .flat() | ||
| .forEach((app) => { | ||
| const appSlug = slugify(app.name) | ||
| paths.push(`/apps/${appSlug}`) | ||
| }) | ||
| } catch (error) { | ||
| console.error("Failed to fetch apps data for revalidation:", error) | ||
| // Continue with category paths even if app fetching fails | ||
| } | ||
|
|
||
| console.log(`Revalidating ${paths.length} paths:`, paths) | ||
| await revalidatePaths(paths) | ||
| }, | ||
| }) |
12 changes: 12 additions & 0 deletions
12
src/data-layer/trigger/old-tasks/revalidate-find-wallet-page.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { schedules } from "@trigger.dev/sdk/v3" | ||
|
|
||
| import { revalidatePaths } from "./utils" | ||
|
|
||
| export const revalidateFindWalletPage = schedules.task({ | ||
| id: "revalidate-find-wallet-page", | ||
| // every day | ||
| cron: "0 0 * * *", | ||
| run: async () => { | ||
| await revalidatePaths(["/wallets/find-wallet/"]) | ||
| }, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { schedules } from "@trigger.dev/sdk/v3" | ||
|
|
||
| import { revalidatePaths } from "./utils" | ||
|
|
||
| export const revalidateHomePage = schedules.task({ | ||
| id: "revalidate-home-page", | ||
| // every day | ||
| cron: "0 0 * * *", | ||
| run: async () => { | ||
| await revalidatePaths(["/"]) | ||
| }, | ||
| }) |
12 changes: 12 additions & 0 deletions
12
src/data-layer/trigger/old-tasks/revalidate-layer-2-networks-page.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { schedules } from "@trigger.dev/sdk/v3" | ||
|
|
||
| import { revalidatePaths } from "./utils" | ||
|
|
||
| export const revalidateLayer2NetworksPage = schedules.task({ | ||
| id: "revalidate-layer-2-networks-page", | ||
| // every day | ||
| cron: "0 0 * * *", | ||
| run: async () => { | ||
| await revalidatePaths(["/layer-2/networks/"]) | ||
| }, | ||
| }) |
12 changes: 12 additions & 0 deletions
12
src/data-layer/trigger/old-tasks/revalidate-layer-2-page.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { schedules } from "@trigger.dev/sdk/v3" | ||
|
|
||
| import { revalidatePaths } from "./utils" | ||
|
|
||
| export const revalidateLayer2Page = schedules.task({ | ||
| id: "revalidate-layer-2-page", | ||
| // every day | ||
| cron: "0 0 * * *", | ||
| run: async () => { | ||
| await revalidatePaths(["/layer-2/"]) | ||
| }, | ||
| }) |
12 changes: 12 additions & 0 deletions
12
src/data-layer/trigger/old-tasks/revalidate-stablecoins-page.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { schedules } from "@trigger.dev/sdk/v3" | ||
|
|
||
| import { revalidatePaths } from "./utils" | ||
|
|
||
| export const revalidateStablecoinsPage = schedules.task({ | ||
| id: "revalidate-stablecoins-page", | ||
| // once a week | ||
| cron: "0 0 * * 1", | ||
| run: async () => { | ||
| await revalidatePaths(["/stablecoins/"]) | ||
| }, | ||
| }) |
12 changes: 12 additions & 0 deletions
12
src/data-layer/trigger/old-tasks/revalidate-staking-page.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { schedules } from "@trigger.dev/sdk/v3" | ||
|
|
||
| import { revalidatePaths } from "./utils" | ||
|
|
||
| export const revalidateStakingPage = schedules.task({ | ||
| id: "revalidate-staking-page", | ||
| // every day | ||
| cron: "0 0 * * *", | ||
| run: async () => { | ||
| await revalidatePaths(["/staking/"]) | ||
| }, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { logger } from "@trigger.dev/sdk/v3" | ||
|
|
||
| export const revalidatePaths = async (paths: string[]) => { | ||
| for (const path of paths) { | ||
| logger.log(`Revalidating ${path}`) | ||
|
|
||
| const url = new URL("https://ethereum.org/api/revalidate/") | ||
| url.searchParams.set("path", path) | ||
| url.searchParams.set("secret", process.env.REVALIDATE_SECRET ?? "") | ||
|
|
||
| const res = await fetch(url) | ||
|
|
||
| if (!res.ok) { | ||
| // 502 "Bad Gateway" error is returned when the on-demand builder (lambda function) | ||
| // hits the timeout limit (30s) | ||
| // https://docs.netlify.com/configure-builds/on-demand-builders/#limits | ||
| if (res.status === 502) { | ||
| logger.warn("On-demand builder timeout", { | ||
| statusText: res.statusText, | ||
| status: res.status, | ||
| }) | ||
|
|
||
| continue | ||
| } | ||
|
|
||
| const message = await res.text() | ||
|
|
||
| logger.error("Failed to revalidate", { | ||
| statusText: res.statusText, | ||
| status: res.status, | ||
| message, | ||
| }) | ||
|
|
||
| throw new Error("Failed to revalidate") | ||
| } | ||
|
|
||
| logger.log(`Finished revalidating ${path}`) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥