Files
2026-02-10 01:14:19 +00:00

30 lines
770 B
TypeScript

import { NextResponse } from "next/server";
import { prisma } from "../../../../../lib/prisma";
export async function GET(req: Request) {
try {
const { searchParams } = new URL(req.url);
const slug = searchParams.get("slug");
if (!slug) {
return NextResponse.json({ error: "slug is required." }, { status: 400 });
}
const store = await prisma.store.findUnique({ where: { slug } });
if (!store) {
return NextResponse.json({ error: "Store not found." }, { status: 404 });
}
return NextResponse.json({
accountId: store.stripeAccountId,
slug: store.slug,
});
} catch (err: any) {
return NextResponse.json(
{ error: err?.message || "Failed to lookup store." },
{ status: 500 }
);
}
}