25 lines
601 B
TypeScript
25 lines
601 B
TypeScript
// make api route to get all sellables
|
|
import { NextResponse } from "next/server";
|
|
import { auth } from "~/server/auth";
|
|
import { db } from "~/server/db";
|
|
|
|
export async function GET() {
|
|
const session = await auth();
|
|
|
|
if (!session) {
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
}
|
|
|
|
const sellables = await db.sellable.findMany({
|
|
include: {
|
|
shop: { select: { label: true } },
|
|
item: { select: { stock: true } },
|
|
},
|
|
});
|
|
// and cache no store header
|
|
|
|
return NextResponse.json(sellables, {
|
|
headers: { "Cache-Control": "no-store" },
|
|
});
|
|
}
|