diff --git a/next.config.ts b/next.config.ts index 2f409ce..c6edece 100644 --- a/next.config.ts +++ b/next.config.ts @@ -30,7 +30,7 @@ const nextConfig: NextConfig = { ], }, { - source: "/((?!sw\\.js|api/pwa-icon).*)", + source: "/((?!sw\\.js).*)", headers: [ { key: "Cache-Control", diff --git a/package-lock.json b/package-lock.json index 5e4375c..66b9aca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,6 @@ "react-leaflet": "^5.0.0", "react-otp-input": "^3.1.1", "react-virtualized": "^9.22.6", - "sharp": "^0.34.5", "tailwind-merge": "^3.3.1", "use-long-press": "^3.3.0", "yup": "^1.7.1", @@ -1860,6 +1859,7 @@ "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.0.0.tgz", "integrity": "sha512-A5P/LfWGFSl6nsckYtjw9da+19jB8hkJ6ACTGcDfEJ0aE+l2n2El7dsVM7UVHZQ9s2lmYMWlrS21YLy2IR1LUw==", "license": "MIT", + "optional": true, "engines": { "node": ">=18" } @@ -5643,6 +5643,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "devOptional": true, "license": "Apache-2.0", "engines": { "node": ">=8" @@ -9623,6 +9624,7 @@ "version": "7.7.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", + "devOptional": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -9692,6 +9694,7 @@ "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==", "hasInstallScript": true, "license": "Apache-2.0", + "optional": true, "dependencies": { "@img/colour": "^1.0.0", "detect-libc": "^2.1.2", diff --git a/package.json b/package.json index 4692ee8..423e971 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "react-leaflet": "^5.0.0", "react-otp-input": "^3.1.1", "react-virtualized": "^9.22.6", - "sharp": "^0.34.5", "tailwind-merge": "^3.3.1", "use-long-press": "^3.3.0", "yup": "^1.7.1", diff --git a/public/icon0.svg b/public/icon0.svg deleted file mode 100644 index 33d5884..0000000 --- a/public/icon0.svg +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/src/app/[name]/api/logo/route.ts b/src/app/[name]/api/logo/route.ts index 045cd5d..b3ce010 100644 --- a/src/app/[name]/api/logo/route.ts +++ b/src/app/[name]/api/logo/route.ts @@ -1,99 +1,13 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { fetchWithTimeout } from "@/lib/helpers/fetchWithTimeout"; import { PWA_ICON_192 } from "@/lib/helpers/pwaIcons"; import { NextRequest, NextResponse } from "next/server"; -import sharp from "sharp"; export const dynamic = "force-dynamic"; export const revalidate = 0; -const FETCH_TIMEOUT_MS = 5000; -const DEFAULT_ICON = PWA_ICON_192; - export async function GET( request: NextRequest, { params }: { params: Promise<{ name: string }> }, ) { - // Restaurant logo processing disabled – redirect to static PWA icon + await params; return NextResponse.redirect(new URL(PWA_ICON_192, request.url), 302); - - /* Restaurant logo processing – uncomment to re-enable dynamic PWA icons - try { - await params; - - const searchParams = request.nextUrl.searchParams; - const logoUrl = searchParams.get("url"); - const size = parseInt(searchParams.get("size") || "192"); - - if (!logoUrl) { - return new NextResponse("Logo URL is required", { status: 400 }); - } - - const imageResponse = await fetchWithTimeout(logoUrl, { - timeoutMs: FETCH_TIMEOUT_MS, - }); - if (!imageResponse.ok) { - return NextResponse.redirect(new URL(DEFAULT_ICON, request.url), 302); - } - - const imageBuffer = Buffer.from(await imageResponse.arrayBuffer()); - - const metadata = await sharp(imageBuffer).metadata(); - const { width, height } = metadata; - - if (!width || !height) { - return NextResponse.redirect(new URL(DEFAULT_ICON, request.url), 302); - } - - if (width === height) { - const processedImage = sharp(imageBuffer).resize(size, size, { - fit: "contain", - background: { r: 0, g: 0, b: 0, alpha: 0 }, - }); - const outputBuffer: any = await processedImage.png().toBuffer(); - - return new NextResponse(outputBuffer, { - headers: { - "Content-Type": "image/png", - "Cache-Control": "public, max-age=31536000, immutable", - }, - }); - } - - const maxDimension = Math.max(width, height); - const scale = size / maxDimension; - const newWidth = Math.round(width * scale); - const newHeight = Math.round(height * scale); - - const paddingTop = Math.floor((size - newHeight) / 2); - const paddingBottom = size - newHeight - paddingTop; - const paddingLeft = Math.floor((size - newWidth) / 2); - const paddingRight = size - newWidth - paddingLeft; - - const processedImage = sharp(imageBuffer) - .resize(newWidth, newHeight, { - fit: "contain", - background: { r: 0, g: 0, b: 0, alpha: 0 }, - }) - .extend({ - top: paddingTop, - bottom: paddingBottom, - left: paddingLeft, - right: paddingRight, - background: { r: 0, g: 0, b: 0, alpha: 0 }, - }); - - const outputBuffer: any = await processedImage.png().toBuffer(); - - return new NextResponse(outputBuffer, { - headers: { - "Content-Type": "image/png", - "Cache-Control": "public, max-age=31536000, immutable", - }, - }); - } catch (error) { - console.error("Error processing logo:", error); - return NextResponse.redirect(new URL(DEFAULT_ICON, request.url), 302); - } - */ } diff --git a/src/app/api/pwa-icon/[size]/route.ts b/src/app/api/pwa-icon/[size]/route.ts deleted file mode 100644 index 05293bd..0000000 --- a/src/app/api/pwa-icon/[size]/route.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { readFile } from 'fs/promises'; -import path from 'path'; -import sharp from 'sharp'; -import { NextRequest, NextResponse } from 'next/server'; - -const VALID_SIZES = [192, 512] as const; - -export async function GET( - _request: NextRequest, - { params }: { params: Promise<{ size: string }> }, -) { - const { size: sizeParam } = await params; - const size = parseInt(sizeParam, 10); - - if (!VALID_SIZES.includes(size as (typeof VALID_SIZES)[number])) { - return new NextResponse('Invalid size', { status: 400 }); - } - - try { - const svgPath = path.join(process.cwd(), 'public', 'icon0.svg'); - const svgBuffer = await readFile(svgPath); - const pngBuffer = await sharp(svgBuffer).resize(size, size).png().toBuffer(); - - return new NextResponse(new Uint8Array(pngBuffer), { - headers: { - 'Content-Type': 'image/png', - 'Cache-Control': 'public, max-age=31536000, immutable', - }, - }); - } catch (error) { - console.error('Error generating PWA icon:', error); - return new NextResponse('Failed to generate icon', { status: 500 }); - } -}