This repository provides a comprehensive solution for managing billboards, categories, and products, allowing you to create a customized online shopping experience similar to Shopify. With intuitive features, you can effortlessly design and organize your store as well.
import { auth } from "@clerk/nextjs";
import { NextResponse } from "next/server";
import prismadb from "@/lib/prismadb";
export async function POST(
req: Request
) {
try {
const { userId } = auth();
// We have access to the current userId who is trying to create a new store
const body = await req.json();
const { name } = body;
if (!userId) {
return new NextResponse("Unauthorized", { status: 401 });
}
if (!name) {
return new NextResponse("Name is required", { status: 400 });
}
const store = await prismadb.store.create({
data: {
name,
userId
}
})
return NextResponse.json(store);
} catch (error) {
console.log('[STORES_POST]', error);
return new NextResponse("Internal Server Error", { status: 500 })
}
}
my
route.ts