21 lines
685 B
JavaScript
21 lines
685 B
JavaScript
import { NextResponse } from "next/server";
|
|
import { addCartItem } from "../../../meshkee";
|
|
|
|
export async function POST(request) {
|
|
const token = request.headers.get("authorization")?.replace(/^Bearer\s+/i, "");
|
|
if (!token) return NextResponse.json({ message: "Missing token" }, { status: 401 });
|
|
|
|
try {
|
|
const body = await request.json();
|
|
const data = await addCartItem({
|
|
businessId: body.businessId,
|
|
token,
|
|
storeItemVariantId: body.storeItemVariantId,
|
|
quantity: body.quantity || 1
|
|
});
|
|
return NextResponse.json(data, { status: 201 });
|
|
} catch {
|
|
return NextResponse.json({ message: "Could not add cart item" }, { status: 502 });
|
|
}
|
|
}
|