Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions app/.well-known/farcaster.json/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
*
*/
export async function GET() {
const URL = process.env.NEXT_PUBLIC_URL;

Expand Down
20 changes: 7 additions & 13 deletions app/api/account-emails/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import { NextRequest, NextResponse } from "next/server";
import getAccountEmails from "@/lib/supabase/account_emails/getAccountEmails";
import { checkAccountArtistAccess } from "@/lib/supabase/account_artist_ids/checkAccountArtistAccess";

/**
*
* @param req
*/
export async function GET(req: NextRequest) {
const accountIds = req.nextUrl.searchParams.getAll("accountIds");
const currentAccountId = req.nextUrl.searchParams.get("currentAccountId");
const artistAccountId = req.nextUrl.searchParams.get("artistAccountId");

if (!currentAccountId || !artistAccountId) {
return NextResponse.json(
{ error: "Missing authentication parameters" },
{ status: 400 }
);
return NextResponse.json({ error: "Missing authentication parameters" }, { status: 400 });
}

if (!accountIds || accountIds.length === 0) {
Expand All @@ -20,10 +21,7 @@ export async function GET(req: NextRequest) {

try {
// Verify current user has access to this artist
const hasAccess = await checkAccountArtistAccess(
currentAccountId,
artistAccountId
);
const hasAccess = await checkAccountArtistAccess(currentAccountId, artistAccountId);

if (!hasAccess) {
return NextResponse.json({ error: "Unauthorized" }, { status: 403 });
Expand All @@ -34,12 +32,8 @@ export async function GET(req: NextRequest) {
const emails = await getAccountEmails(accountIds);
return NextResponse.json(emails);
} catch {
return NextResponse.json(
{ error: "Failed to fetch account emails" },
{ status: 500 }
);
return NextResponse.json({ error: "Failed to fetch account emails" }, { status: 500 });
}
}

export const dynamic = "force-dynamic";

8 changes: 5 additions & 3 deletions app/api/agent-creator/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { NextRequest } from "next/server";

export const runtime = "edge";

/**
*
* @param req
*/
export async function GET(req: NextRequest) {
const creatorId = req.nextUrl.searchParams.get("creatorId");

Expand All @@ -18,9 +22,7 @@ export async function GET(req: NextRequest) {
return Response.json({ message: "Creator not found" }, { status: 404 });
}

const info = Array.isArray(account.account_info)
? account.account_info[0] || null
: null;
const info = Array.isArray(account.account_info) ? account.account_info[0] || null : null;
const email = Array.isArray(account.account_emails)
? account.account_emails[0]?.email || null
: null;
Expand Down
10 changes: 7 additions & 3 deletions app/api/agent-templates/favorites/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import type { ToggleFavoriteRequest, ToggleFavoriteResponse } from "@/types/Agen

export const runtime = "edge";

/**
*
* @param request
*/
export async function POST(request: Request) {
try {
const { templateId, userId, isFavourite }: ToggleFavoriteRequest = await request.json();
Expand All @@ -22,11 +26,11 @@ export async function POST(request: Request) {
return NextResponse.json({ success: true } as ToggleFavoriteResponse);
} catch (error) {
console.error("Error toggling favourite:", error);
return NextResponse.json({ error: "Failed to toggle favourite" } as ToggleFavoriteResponse, { status: 500 });
return NextResponse.json({ error: "Failed to toggle favourite" } as ToggleFavoriteResponse, {
status: 500,
});
}
}

export const dynamic = "force-dynamic";
export const revalidate = 0;


24 changes: 20 additions & 4 deletions app/api/agent-templates/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { getSharedEmailsForTemplates } from "@/lib/supabase/agent_templates/getS

export const runtime = "edge";

/**
*
* @param request
*/
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
Expand All @@ -29,16 +33,20 @@ export async function GET(request: Request) {
// Add shared emails to templates
const templatesWithEmails = templates.map(template => ({
...template,
shared_emails: template.is_private ? (sharedEmails[template.id] || []) : []
shared_emails: template.is_private ? sharedEmails[template.id] || [] : [],
}));

return NextResponse.json(templatesWithEmails);
} catch (error) {
console.error('Error fetching agent templates:', error);
return NextResponse.json({ error: 'Failed to fetch templates' }, { status: 500 });
console.error("Error fetching agent templates:", error);
return NextResponse.json({ error: "Failed to fetch templates" }, { status: 500 });
}
}

/**
*
* @param request
*/
export async function POST(request: Request) {
try {
const body = await request.json();
Expand Down Expand Up @@ -76,6 +84,10 @@ export async function POST(request: Request) {
}
}

/**
*
* @param request
*/
export async function DELETE(request: Request) {
try {
const { id, userId } = (await request.json()) as { id: string; userId: string };
Expand All @@ -96,6 +108,10 @@ export async function DELETE(request: Request) {
}
}

/**
*
* @param request
*/
export async function PATCH(request: Request) {
try {
const body = await request.json();
Expand Down Expand Up @@ -150,4 +166,4 @@ export async function PATCH(request: Request) {
}

export const dynamic = "force-dynamic";
export const revalidate = 0;
export const revalidate = 0;
4 changes: 4 additions & 0 deletions app/api/agentkit/get/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import getPostComments from "@/lib/getPostComments";
import supabase from "@/lib/supabase/serverClient";
import { NextRequest, NextResponse } from "next/server";

/**
*
* @param req
*/
export async function GET(req: NextRequest) {
const agentId = req.nextUrl.searchParams.get("agentId");
try {
Expand Down
14 changes: 7 additions & 7 deletions app/api/agentkit/run/route.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { NextResponse } from "next/server";

/**
*
*/
export async function GET() {
try {
const response = await fetch(
"http://143.198.164.177:3000/api/agentkit/run",
{
headers: {
"Content-Type": "application/json",
},
const response = await fetch("http://143.198.164.177:3000/api/agentkit/run", {
headers: {
"Content-Type": "application/json",
},
);
});
const data = await response.json();
return NextResponse.json(data);
} catch (error) {
Expand Down
14 changes: 6 additions & 8 deletions app/api/agents/route.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { NextRequest, NextResponse } from "next/server";
import { getArtistAgents } from "@/lib/supabase/getArtistAgents";

/**
*
* @param request
*/
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const socialIds = searchParams.getAll("socialId");

if (!socialIds.length) {
return NextResponse.json(
{ error: "At least one Social ID is required" },
{ status: 400 },
);
return NextResponse.json({ error: "At least one Social ID is required" }, { status: 400 });
}

try {
const agents = await getArtistAgents(socialIds);
return NextResponse.json(agents);
} catch (error) {
console.error("Error fetching segments:", error);
return NextResponse.json(
{ error: "Failed to fetch segments" },
{ status: 500 },
);
return NextResponse.json({ error: "Failed to fetch segments" }, { status: 500 });
}
}

Expand Down
10 changes: 6 additions & 4 deletions app/api/apify/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ 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.
*
* @param req
*/
export async function POST(req: NextRequest) {
try {
Expand All @@ -28,10 +30,10 @@ export async function POST(req: NextRequest) {
});
} 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" } }
);
return new Response(JSON.stringify({ message: "Apify webhook received (invalid JSON)" }), {
status: 200,
headers: { "Content-Type": "application/json" },
});
}
}

Expand Down
8 changes: 5 additions & 3 deletions app/api/artist/get_fan_segments/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import supabase from "@/lib/supabase/serverClient";
import { NextRequest } from "next/server";

/**
*
* @param req
*/
export async function GET(req: NextRequest) {
const artistId = req.nextUrl.searchParams.get("artistId");

Expand All @@ -11,9 +15,7 @@ export async function GET(req: NextRequest) {
.eq("account_id", artistId);
if (!account_socials) throw new Error("failed");

const account_social_ids = account_socials.map(
(account_social) => account_social.social.id,
);
const account_social_ids = account_socials.map(account_social => account_social.social.id);

const { data: fan_segments } = await supabase
.from("artist_fan_segment")
Expand Down
6 changes: 5 additions & 1 deletion app/api/artist/pin/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ import { toggleArtistPin } from "@/lib/supabase/account_artist_ids/toggleArtistP

export const runtime = "edge";

/**
*
* @param req
*/
export async function POST(req: NextRequest) {
const body = await req.json();
const { accountId, artistId, pinned } = body;

if (!accountId || !artistId || typeof pinned !== "boolean") {
return Response.json(
{ message: "Missing required fields: accountId, artistId, pinned" },
{ status: 400 }
{ status: 400 },
);
}

Expand Down
8 changes: 6 additions & 2 deletions app/api/artist/profile/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import updateArtistSocials from "@/lib/supabase/updateArtistSocials";
import { addArtistToOrganization } from "@/lib/supabase/artist_organization_ids/addArtistToOrganization";
import { NextRequest } from "next/server";

/**
*
* @param req
*/
export async function POST(req: NextRequest) {
const body = await req.json();
const image = body.image;
Expand All @@ -28,7 +32,7 @@ export async function POST(req: NextRequest) {
name,
instruction,
label,
knowledges
knowledges,
);

await updateArtistSocials(artistAccountId as string, profileUrls);
Expand All @@ -49,7 +53,7 @@ export async function POST(req: NextRequest) {
{
artist: getFormattedArtist(account),
},
{ status: 200 }
{ status: 200 },
);
} catch (error) {
console.error(error);
Expand Down
4 changes: 4 additions & 0 deletions app/api/artist/remove/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import supabase from "@/lib/supabase/serverClient";
import { NextRequest } from "next/server";

/**
*
* @param req
*/
export async function GET(req: NextRequest) {
const artistId = req.nextUrl.searchParams.get("artistId");

Expand Down
Loading
Loading