diff --git a/app/api/agentkit/get/route.ts b/app/api/agentkit/get/route.ts deleted file mode 100644 index 885c9018b..000000000 --- a/app/api/agentkit/get/route.ts +++ /dev/null @@ -1,54 +0,0 @@ -import getPostComments from "@/lib/getPostComments"; -import supabase from "@/lib/supabase/serverClient"; -import { NextRequest, NextResponse } from "next/server"; - -export async function GET(req: NextRequest) { - const agentId = req.nextUrl.searchParams.get("agentId"); - try { - const { data } = await supabase - .from("agents") - .select( - ` - *, - agent_status ( - *, - social:socials ( - *, - social_posts ( - *, - posts ( - * - ) - ), - social_spotify_tracks ( - *, - spotify_tracks ( - * - ) - ), - social_spotify_albums ( - *, - spotify_albums ( - * - ) - ) - ) - ) - `, - ) - .eq("id", agentId) - .single(); - const comments = await getPostComments(data.agent_status); - return NextResponse.json({ - data, - comments, - }); - } catch (error) { - console.error("Error:", error); - return NextResponse.json({ error: "Failed to fetch" }, { status: 500 }); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/app/api/apify/route.ts b/app/api/apify/route.ts deleted file mode 100644 index 154deda94..000000000 --- a/app/api/apify/route.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { NextRequest } from "next/server"; -import handleApifyWebhook from "@/lib/apify/handleApifyWebhook"; -import apifyPayloadSchema from "@/lib/apify/apifyPayloadSchema"; - -/** - * API endpoint for Apify webhooks. - * Accepts a POST request with a JSON payload, optionally fetches a dataset, and always responds with 200. - */ -export async function POST(req: NextRequest) { - try { - const body = await req.json(); - // Optionally validate the payload shape - const parsed = apifyPayloadSchema.safeParse(body); - console.log("Received Apify webhook:", parsed); - - if (!parsed.success) { - return new Response(JSON.stringify({ message: "Invalid payload" }), { - status: 400, - headers: { "Content-Type": "application/json" }, - }); - } - const result = await handleApifyWebhook(parsed.data); - console.log("handleApifyWebhook result:", result); - - return new Response(JSON.stringify(result), { - status: 200, - headers: { "Content-Type": "application/json" }, - }); - } catch { - // Always respond with 200, even if parsing fails - return new Response( - JSON.stringify({ message: "Apify webhook received (invalid JSON)" }), - { status: 200, headers: { "Content-Type": "application/json" } } - ); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/app/api/funnel_analysis/route.ts b/app/api/funnel_analysis/route.ts deleted file mode 100644 index 52eb0d8bc..000000000 --- a/app/api/funnel_analysis/route.ts +++ /dev/null @@ -1,19 +0,0 @@ -import getFunnelAnalysis from "@/lib/chat/getFunnelAnalysis"; -import { NextRequest } from "next/server"; - -export async function GET(req: NextRequest) { - const pilotId = req.nextUrl.searchParams.get("pilotId"); - - try { - const data = await getFunnelAnalysis(pilotId as string); - return Response.json({ data }, { status: 200 }); - } catch (error) { - console.error(error); - const message = error instanceof Error ? error.message : "failed"; - return Response.json({ message }, { status: 400 }); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/app/api/get_artists_by_socials/route.tsx b/app/api/get_artists_by_socials/route.tsx deleted file mode 100644 index 35396bbc7..000000000 --- a/app/api/get_artists_by_socials/route.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import supabase from "@/lib/supabase/serverClient"; -import { NextRequest } from "next/server"; - -export async function POST(req: NextRequest) { - const body = await req.json(); - const socialIds = body.socialIds; - - try { - const { data: account_socials } = await supabase - .from("account_socials") - .select("*, account:accounts(*)") - .in("social_id", socialIds); - if (!account_socials) throw new Error("failed"); - - const accountIds = account_socials.map( - (account_social) => account_social.account.id, - ); - const artistIds = [...new Set(accountIds)]; - - return Response.json({ artistIds }, { status: 200 }); - } catch (error) { - console.error(error); - const message = error instanceof Error ? error.message : "failed"; - return Response.json({ message }, { status: 400 }); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/app/api/get_running_agent/route.ts b/app/api/get_running_agent/route.ts deleted file mode 100644 index 313671738..000000000 --- a/app/api/get_running_agent/route.ts +++ /dev/null @@ -1,44 +0,0 @@ -import supabase from "@/lib/supabase/serverClient"; -import { STEP_OF_AGENT } from "@/types/Funnel"; -import { NextRequest } from "next/server"; - -export async function GET(req: NextRequest) { - const artistId = req.nextUrl.searchParams.get("artistId"); - try { - const { data: account } = await supabase - .from("accounts") - .select("*, account_socials(*)") - .eq("id", artistId) - .single(); - - if (!account) return Response.json({ agent: null }, { status: 200 }); - - const social_ids = account.account_socials.map( - // eslint-disable-next-line - (account_social: any) => account_social.social_id, - ); - - const { data: agent_status } = await supabase - .from("agent_status") - .select("*, social:socials(*), agent:agents(*)") - .in("social_id", social_ids) - .neq("status", STEP_OF_AGENT.FINISHED) - .neq("status", STEP_OF_AGENT.ERROR) - .neq("status", STEP_OF_AGENT.UNKNOWN_PROFILE) - .neq("status", STEP_OF_AGENT.RATE_LIMIT_EXCEEDED) - .neq("status", STEP_OF_AGENT.MISSING_POSTS) - .order("updated_at", { ascending: false }) - .limit(1) - .single(); - - return Response.json({ agent: agent_status }, { status: 200 }); - } catch (error) { - console.error(error); - const message = error instanceof Error ? error.message : "failed"; - return Response.json({ message }, { status: 400 }); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/app/api/ipfs/route.tsx b/app/api/ipfs/route.tsx deleted file mode 100644 index 43e80414a..000000000 --- a/app/api/ipfs/route.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import saveFile from "@/lib/ipfs/saveFile"; -import { NextRequest } from "next/server"; - -export async function POST(request: NextRequest) { - const data = await request.formData(); - const file: File | null = data.get("file") as unknown as File; - data.append("file", file); - data.append("pinataMetadata", JSON.stringify({ name: "File to upload" })); - const cid = await saveFile(data); - return Response.json({ cid }, { status: 200 }); -} diff --git a/app/api/stripe/session/checked/route.ts b/app/api/stripe/session/checked/route.ts deleted file mode 100644 index f8b69d19c..000000000 --- a/app/api/stripe/session/checked/route.ts +++ /dev/null @@ -1,30 +0,0 @@ -import stripeClient from "@/lib/stripe/client"; -import { NextRequest } from "next/server"; - -export async function GET(req: NextRequest) { - const sessionId = req.nextUrl.searchParams.get("sessionId"); - const accountId = req.nextUrl.searchParams.get("accountId"); - - if (!sessionId) { - return Response.json({ message: "sessionId is required" }, { status: 400 }); - } - - try { - const session = await stripeClient.checkout.sessions.update(sessionId, { - metadata: { - credit_updated: "credit_updated", - accountId, - }, - }); - - return Response.json({ data: session }, { status: 200 }); - } catch (error) { - console.error(error); - const message = error instanceof Error ? error.message : "failed"; - return Response.json({ message }, { status: 400 }); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/app/api/stripe/session/list/route.ts b/app/api/stripe/session/list/route.ts deleted file mode 100644 index 4ea241fa2..000000000 --- a/app/api/stripe/session/list/route.ts +++ /dev/null @@ -1,27 +0,0 @@ -import stripeClient from "@/lib/stripe/client"; -import { NextRequest } from "next/server"; - -export async function GET(req: NextRequest) { - const referenceId = req.nextUrl.searchParams.get("referenceId"); - - try { - const sessions = await stripeClient.checkout.sessions.list({ - limit: 100, - }); - - const session = sessions.data.find( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (item: any) => item.client_reference_id === referenceId, - ); - - return Response.json({ data: session }, { status: 200 }); - } catch (error) { - console.error(error); - const message = error instanceof Error ? error.message : "failed"; - return Response.json({ message }, { status: 400 }); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/app/api/upload/pfp/route.tsx b/app/api/upload/pfp/route.tsx deleted file mode 100644 index 77c1378d6..000000000 --- a/app/api/upload/pfp/route.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import uploadPfpToIpfs from "@/lib/uploadPfpToIpfs"; -import { NextRequest } from "next/server"; - -export async function POST(req: NextRequest) { - const body = await req.json(); - const url = body.image; - try { - const pfp = await uploadPfpToIpfs(url); - return Response.json({ success: true, image: pfp }, { status: 200 }); - } catch (error) { - console.error(error); - return Response.json({ image: null, success: false }, { status: 500 }); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/app/api/workspace/create/route.ts b/app/api/workspace/create/route.ts deleted file mode 100644 index ea7f599fb..000000000 --- a/app/api/workspace/create/route.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { NextRequest } from "next/server"; -import { NEW_API_BASE_URL } from "@/lib/consts"; - -/** - * @deprecated This endpoint is deprecated. Use recoup-api directly at POST /api/workspaces - * - * Create a blank workspace for an account. - * This route now proxies to recoup-api for workspace creation. - */ -export async function POST(req: NextRequest) { - const sunsetDate = new Date("2026-03-01"); - const deprecationHeaders = { - Deprecation: "true", - Sunset: sunsetDate.toUTCString(), - Link: `<${NEW_API_BASE_URL}/api/workspaces>; rel="deprecation"`, - }; - - try { - const body = await req.text(); - - // Forward auth headers to recoup-api - const headers = new Headers(); - const authHeader = req.headers.get("authorization"); - const apiKeyHeader = req.headers.get("x-api-key"); - - if (authHeader) { - headers.set("authorization", authHeader); - } - if (apiKeyHeader) { - headers.set("x-api-key", apiKeyHeader); - } - headers.set("Content-Type", "application/json"); - - const response = await fetch(`${NEW_API_BASE_URL}/api/workspaces`, { - method: "POST", - headers, - body, - }); - - const responseData = await response.json(); - - return Response.json(responseData, { - status: response.status, - headers: deprecationHeaders, - }); - } catch (error) { - console.error("Error proxying workspace creation:", error); - const message = error instanceof Error ? error.message : "Failed to create workspace"; - return Response.json( - { status: "error", error: message }, - { status: 500, headers: deprecationHeaders } - ); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/components/SocialSharing/SocialSharing.tsx b/components/SocialSharing/SocialSharing.tsx deleted file mode 100644 index 68c3ff272..000000000 --- a/components/SocialSharing/SocialSharing.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import React, { useState } from "react"; -import HeatMap from "@uiw/react-heat-map"; -import useActivities from "@/hooks/useActivities"; -import { Twitter, Download } from "lucide-react"; -import { ONE_DAY_MILLISECONDS } from "@/lib/consts"; -import useShareHeatMap from "@/hooks/useShareHeatMap"; - -const SocialSharing = () => { - const today = new Date(); - const { activities } = useActivities(); - const { heatmap, download, tweets, loading } = useShareHeatMap(); - const [x, setX] = useState(0); - const [y, setY] = useState(0); - const [tooltipActive, setTooltipActive] = useState(false); - const [tooltipContent, setTooltipContent] = useState(""); - - return ( -
- {activities?.length > 0 && ( - <> -
- { - if (!data.count) return ; - return ( - { - setX(Number(props?.x)); - setY(Number(props?.y)); - setTooltipContent(data.count.toString()); - setTooltipActive(true); - }} - onMouseLeave={() => { - setTooltipActive(false); - setX(-1000000); - setY(-1000000); - setTooltipContent(""); - }} - /> - ); - }} - /> - {tooltipActive && ( -
- {tooltipContent} -
- )} -
-
- - -
- - )} -
- ); -}; - -export default SocialSharing; diff --git a/components/SocialSharing/index.tsx b/components/SocialSharing/index.tsx deleted file mode 100644 index 14851ead4..000000000 --- a/components/SocialSharing/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import SocialSharing from "./SocialSharing"; - -export default SocialSharing; diff --git a/hooks/useShareHeatMap.tsx b/hooks/useShareHeatMap.tsx deleted file mode 100644 index 18578b0e7..000000000 --- a/hooks/useShareHeatMap.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { uploadFile } from "@/lib/ipfs/uploadToIpfs"; -import { useEffect, useRef, useState } from "react"; -import domtoimage from "dom-to-image"; -import getIpfsLink from "@/lib/ipfs/getIpfsLink"; - -const useShareHeatMap = () => { - const heatmap = useRef() as any; - const [loading, setLoading] = useState(false); - const [blob, setBlob] = useState(null); - - const download = async () => { - if (!blob) return; - setLoading(true); - const url = URL.createObjectURL(blob); - const a = document.createElement("a"); - a.href = url; - a.download = "heatmap.png"; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - setLoading(false); - }; - - const tweets = async () => { - if (!blob) return; - setLoading(true); - const fileName = "heatmap.png"; - const fileType = "image/png"; - const mapFile = new File([blob], fileName, { type: fileType }); - const { cid } = await uploadFile(mapFile); - const tweetLink = `https://x.com/intent/tweet?text=${encodeURIComponent(getIpfsLink(`ipfs://${cid}`))}`; - window.open(tweetLink, "_blank"); - setLoading(false); - }; - - useEffect(() => { - const init = async () => { - const domBlob = await domtoimage.toBlob(heatmap.current); - setBlob(domBlob); - }; - if (!heatmap.current) return; - init(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [heatmap.current]); - - return { - loading, - download, - tweets, - blob, - heatmap, - }; -}; - -export default useShareHeatMap; diff --git a/lib/chat/getFunnelAnalysis.tsx b/lib/chat/getFunnelAnalysis.tsx deleted file mode 100644 index 686b39ded..000000000 --- a/lib/chat/getFunnelAnalysis.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import supabase from "../supabase/serverClient"; - -const getFunnelAnalysis = async (pilotId: string) => { - const { data } = await supabase - .from("funnel_analytics") - .select( - `*, - accounts ( - *, - account_info ( - * - ), - account_socials ( - * - ) - ), - funnel_analytics_segments ( - icon, - name, - size - ), - funnel_analytics_accounts ( - *, - accounts ( - *, - account_info ( - * - ), - account_socials ( - * - ) - ) - ), - funnel_analytics_comments ( - post_url, - comment, - username, - type, - timestamp - )`, - ) - .eq("pilot_id", pilotId); - - return data; -}; - -export default getFunnelAnalysis; diff --git a/lib/getArtistsByAgent.tsx b/lib/getArtistsByAgent.tsx deleted file mode 100644 index 9daed97ea..000000000 --- a/lib/getArtistsByAgent.tsx +++ /dev/null @@ -1,25 +0,0 @@ -// eslint-disable-next-line -const getArtistsByAgent = async (agent: any) => { - try { - const socialIds = agent.agent_status.map( - // eslint-disable-next-line - (agent_status: any) => agent_status.social_id, - ); - const response = await fetch("/api/get_artists_by_socials", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ socialIds }), - }); - - const data = await response.json(); - - return data.artistIds || []; - } catch (error) { - console.error(error); - return []; - } -}; - -export default getArtistsByAgent; diff --git a/lib/getFunnelAnalysis.tsx b/lib/getFunnelAnalysis.tsx deleted file mode 100644 index 829b07e31..000000000 --- a/lib/getFunnelAnalysis.tsx +++ /dev/null @@ -1,7 +0,0 @@ -const getFunnelAnalysis = async (chatId: string) => { - const response = await fetch(`/api/funnel_analysis?pilotId=${chatId}`); - const data = await response.json(); - return data.data; -}; - -export default getFunnelAnalysis; diff --git a/lib/getFunnelChatContext.tsx b/lib/getFunnelChatContext.tsx deleted file mode 100644 index dbc62d6e7..000000000 --- a/lib/getFunnelChatContext.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import getFunnelAnalysis from "./getFunnelAnalysis"; - -const getFunnelChatContext = async (active_analaysis_id: string) => { - if (!active_analaysis_id) return ""; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let funnelAnalaysisContext: any = null; - if (active_analaysis_id) - funnelAnalaysisContext = await getFunnelAnalysis(active_analaysis_id); - if (funnelAnalaysisContext) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const postComments: any = []; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const segments: any = []; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - funnelAnalaysisContext?.map((funnel_analysis: any) => { - postComments.push(funnel_analysis.funnel_analytics_comments); - segments.push(funnel_analysis.funnel_analytics_segments); - }); - return JSON.stringify({ - PostContents: postComments.flat(), - // eslint-disable-next-line @typescript-eslint/no-explicit-any - Experties: segments.flat().map((segment: any) => segment.name), - }); - } - - return ""; -}; - -export default getFunnelChatContext; diff --git a/lib/getRunningAgent.tsx b/lib/getRunningAgent.tsx deleted file mode 100644 index 8c1fdef73..000000000 --- a/lib/getRunningAgent.tsx +++ /dev/null @@ -1,14 +0,0 @@ -const getRunningAgent = async (artistId: string) => { - try { - const response = await fetch(`/api/get_running_agent?artistId=${artistId}`); - - const data = await response.json(); - - return data.agent; - } catch (error) { - console.error(error); - return []; - } -}; - -export default getRunningAgent; diff --git a/lib/ipfs/getIpfsLink.tsx b/lib/ipfs/getIpfsLink.tsx deleted file mode 100644 index 57275f308..000000000 --- a/lib/ipfs/getIpfsLink.tsx +++ /dev/null @@ -1,8 +0,0 @@ -const getIpfsLink = (hash: string): string => { - if (!hash) return ""; - return hash?.indexOf?.("ipfs://") > -1 - ? hash.replace("ipfs://", `https://ipfs.decentralized-content.com/ipfs/`) - : hash; -}; - -export default getIpfsLink; diff --git a/lib/ipfs/hash.ts b/lib/ipfs/hash.ts deleted file mode 100644 index d4a62c7de..000000000 --- a/lib/ipfs/hash.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as crypto from "crypto"; - -export function hashFiles(files: File[]): string { - const hash = crypto.createHash("sha256"); - for (const file of files) { - const simplifiedFile = { - name: file.name, - lastModified: file.lastModified, - size: file.size, - type: file.type, - }; - hash.update(JSON.stringify(simplifiedFile)); - } - return `0x${hash.digest("hex")}`; -} diff --git a/lib/ipfs/saveFile.tsx b/lib/ipfs/saveFile.tsx deleted file mode 100644 index 97619f90d..000000000 --- a/lib/ipfs/saveFile.tsx +++ /dev/null @@ -1,21 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const saveFile = async (data: any) => { - try { - const response = await fetch( - "https://api.pinata.cloud/pinning/pinFileToIPFS", - { - method: "POST", - headers: { - Authorization: `Bearer ${process.env.PINATA_JWT}`, - }, - body: data, - }, - ); - const { IpfsHash } = await response.json(); - return IpfsHash; - } catch (error) { - throw error; - } -}; - -export default saveFile; diff --git a/lib/ipfs/upload.ts b/lib/ipfs/upload.ts deleted file mode 100644 index 69d565f08..000000000 --- a/lib/ipfs/upload.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { hashFiles } from "./hash"; - -export type IPFSUploadResponse = { - cid: string; - uri: string; -}; - -const uploadCache = { - prefix: "Pinata/IPFSUploadCache", - get(files: File[]): IPFSUploadResponse | undefined { - const digest = hashFiles(files); - try { - const cid = localStorage.getItem(`${this.prefix}/${digest}`); - if (cid) { - return { cid, uri: `ipfs://${cid}` }; - } - } catch {} - }, - put(files: File[], cid: string) { - const digest = hashFiles(files); - try { - localStorage.setItem(`${this.prefix}/${digest}`, cid); - } catch {} - }, -}; - -export const uploadFile = async (file: File): Promise => { - try { - const data = new FormData(); - data.set("file", file); - const cached = uploadCache.get([file]); - if (cached) return cached; - const res = await fetch("/api/ipfs", { - method: "POST", - body: data, - }); - const json = await res.json(); - const { cid } = json; - uploadCache.put([file], cid); - return { cid, uri: `ipfs://${cid}` }; - } catch (error) { - console.error(error); - return { cid: "", uri: "" }; - } -}; diff --git a/lib/ipfs/uploadToIpfs.tsx b/lib/ipfs/uploadToIpfs.tsx deleted file mode 100644 index 69d565f08..000000000 --- a/lib/ipfs/uploadToIpfs.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { hashFiles } from "./hash"; - -export type IPFSUploadResponse = { - cid: string; - uri: string; -}; - -const uploadCache = { - prefix: "Pinata/IPFSUploadCache", - get(files: File[]): IPFSUploadResponse | undefined { - const digest = hashFiles(files); - try { - const cid = localStorage.getItem(`${this.prefix}/${digest}`); - if (cid) { - return { cid, uri: `ipfs://${cid}` }; - } - } catch {} - }, - put(files: File[], cid: string) { - const digest = hashFiles(files); - try { - localStorage.setItem(`${this.prefix}/${digest}`, cid); - } catch {} - }, -}; - -export const uploadFile = async (file: File): Promise => { - try { - const data = new FormData(); - data.set("file", file); - const cached = uploadCache.get([file]); - if (cached) return cached; - const res = await fetch("/api/ipfs", { - method: "POST", - body: data, - }); - const json = await res.json(); - const { cid } = json; - uploadCache.put([file], cid); - return { cid, uri: `ipfs://${cid}` }; - } catch (error) { - console.error(error); - return { cid: "", uri: "" }; - } -}; diff --git a/lib/stripe/getSession.tsx b/lib/stripe/getSession.tsx deleted file mode 100644 index 63db0326a..000000000 --- a/lib/stripe/getSession.tsx +++ /dev/null @@ -1,12 +0,0 @@ -export const getSession = async (referenceId: string) => { - try { - const response = await fetch( - `/api/stripe/session/list?referenceId=${referenceId}`, - ); - - const data = await response.json(); - return data.data; - } catch (error) { - return { error }; - } -}; diff --git a/lib/uploadPfp.tsx b/lib/uploadPfp.tsx deleted file mode 100644 index 4569fb891..000000000 --- a/lib/uploadPfp.tsx +++ /dev/null @@ -1,18 +0,0 @@ -const uploadPfp = async (image: string) => { - try { - const response = await fetch("/api/upload/pfp", { - method: "POST", - body: JSON.stringify({ image }), - headers: { - "Content-Type": "application/json", - }, - }); - const data = await response.json(); - return data.image; - } catch (error) { - console.error(error); - return ""; - } -}; - -export default uploadPfp; diff --git a/lib/uploadPfpToIpfs.tsx b/lib/uploadPfpToIpfs.tsx deleted file mode 100644 index 134e61332..000000000 --- a/lib/uploadPfpToIpfs.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import getBlob from "./getBlob"; -import { uploadToIpfs } from "./ipfs"; - -const uploadPfpToIpfs = async (image: string) => { - const { blob, type } = await getBlob(image); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const avatarBlob = new Blob([blob as any], { type }); - const fileName = "avatar.png"; - const avatarFile = new File([avatarBlob], fileName, { type }); - const avatarCid = await uploadToIpfs(avatarFile); - - return `https://ipfs.decentralized-content.com/ipfs/${avatarCid}`; -}; - -export default uploadPfpToIpfs;