chore: transfer repo
This commit is contained in:
21
app/api/products/route.ts
Normal file
21
app/api/products/route.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { getBoxProducts, getProducts } from 'lib/shopify';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
// Get query parameters
|
||||
const { searchParams } = new URL(request.url);
|
||||
const type = searchParams.get('type');
|
||||
|
||||
if (type === 'boxes') {
|
||||
const boxProducts = await getBoxProducts({});
|
||||
return NextResponse.json({ products: boxProducts });
|
||||
} else {
|
||||
const allProducts = await getProducts({});
|
||||
return NextResponse.json({ products: allProducts });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching products:', error);
|
||||
return NextResponse.json({ error: 'Failed to fetch products' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
6
app/api/revalidate/route.ts
Normal file
6
app/api/revalidate/route.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { revalidate } from 'lib/shopify';
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||
return revalidate(req);
|
||||
}
|
||||
Reference in New Issue
Block a user