Skip to content

Commit

Permalink
Merge pull request #251 from framesjs/fix/refactor-frames-examples
Browse files Browse the repository at this point in the history
fix: refactor frames examples
  • Loading branch information
stephancill authored Mar 27, 2024
2 parents d860bc2 + 4451b7c commit 6142ac5
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-dots-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"framesjs-starter": patch
---

fix: refactor frames app into frames.ts in examples
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createFrames } from "frames.js/next";

export const frames = createFrames({
basePath: "/examples/new-api-cache-control",
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* eslint-disable react/jsx-key */
import { Button } from "frames.js/next";
import { createFrames } from "frames.js/next";

const frames = createFrames({
basePath: "/examples/new-api-cache-control",
});
import { frames } from "./frames";

const handleRequest = frames(async (ctx) => {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createFrames } from "frames.js/next";

export const frames = createFrames({
basePath: "/examples/new-api-mint-button/frames",
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable react/jsx-key */
import { Button, createFrames } from "frames.js/next";
import { Button } from "frames.js/next";
import { getTokenUrl } from "frames.js";
import { zora } from "viem/chains";
import { frames } from "./frames";

const nfts: {
src: string;
Expand Down Expand Up @@ -33,10 +34,6 @@ const nfts: {
},
];

const frames = createFrames({
basePath: "/examples/new-api-mint-button/frames",
});

const handleRequest = frames(async (ctx) => {
const page = Number(ctx.searchParams?.pageIndex ?? 0);
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import { farcasterHubContext, openframes } from "frames.js/middleware";
import { createFrames } from "frames.js/next";
import { getXmtpFrameMessage, isXmtpFrameActionPayload } from "frames.js/xmtp";
import { DEFAULT_DEBUGGER_HUB_URL } from "../../debug";
import { DEFAULT_DEBUGGER_HUB_URL } from "../../../debug";

export const frames = createFrames({
basePath: "/examples/new-api-multi-protocol",
basePath: "/examples/new-api-multi-protocol/frames",
initialState: {
pageIndex: 0,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button } from "frames.js/next";
import { frames } from "../frames";
import { frames } from "./frames";

const handleRequest = frames(async (ctx) => {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { farcasterHubContext } from "frames.js/middleware";
import { createFrames } from "frames.js/next";
import { DEFAULT_DEBUGGER_HUB_URL } from "../../../debug";

export const frames = createFrames({
basePath: "/examples/new-api-only-followers-can-mint/frames",
middleware: [
farcasterHubContext({
hubHttpUrl: DEFAULT_DEBUGGER_HUB_URL,
}),
],
});
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
/* eslint-disable react/jsx-key */
import { getTokenUrl } from "frames.js";
import { farcasterHubContext } from "frames.js/middleware";
import { Button, createFrames } from "frames.js/next";
import { Button } from "frames.js/next";
import { zora } from "viem/chains";
import { DEFAULT_DEBUGGER_HUB_URL } from "../../../debug";

const frames = createFrames({
basePath: "/examples/new-api-only-followers-can-mint/frames",
middleware: [
farcasterHubContext({
hubHttpUrl: DEFAULT_DEBUGGER_HUB_URL,
}),
],
});
import { frames } from "./frames";

const handleRequest = frames(async (ctx) => {
const page = ctx.searchParams?.page ?? "initial";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createFrames } from "frames.js/next";

export const frames = createFrames({
basePath: "/examples/new-api-post-redirect/frames",
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-disable react/jsx-key */
import { createFrames, Button } from "frames.js/next";
import { Button } from "frames.js/next";
import { redirect } from "frames.js/core";

const frames = createFrames({
basePath: "/examples/new-api-post-redirect/frames",
});
import { frames } from "./frames";

const handleRequest = frames(async (ctx) => {
if (ctx.pressedButton?.action === "post_redirect") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createFrames } from "frames.js/next";

export const frames = createFrames({
basePath: "/examples/new-api-slow-request/frames",
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { kv } from "@vercel/kv";
import { types } from "frames.js/core";
import { createFrames, Button } from "frames.js/next";
import { Button } from "frames.js/next";
import { RandomNumberRequestStateValue } from "../slow-fetch/types";

const frames = createFrames({
basePath: "/examples/new-api-slow-request/frames",
});
import { frames } from "./frames";

const handleRequest = frames(async (ctx) => {
const initialFrame = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createFrames } from "frames.js/next";

export const frames = createFrames({
basePath: "/examples/new-api-transaction",
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* eslint-disable react/jsx-key */
import { Button } from "frames.js/next";
import { createFrames } from "frames.js/next";

const frames = createFrames({
basePath: "/examples/new-api-transaction",
});
import { frames } from "./frames";

const handleRequest = frames(async (ctx) => {
if (ctx.message?.transactionId) {
Expand Down

0 comments on commit 6142ac5

Please sign in to comment.