Skip to content

Commit

Permalink
add catch log
Browse files Browse the repository at this point in the history
  • Loading branch information
secondl1ght committed May 23, 2024
1 parent 3b83c8e commit bd7fe0f
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/routes/og/merchant/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ import { generateImage } from '../generateImage';
import type { RequestHandler } from './$types';

export const GET: RequestHandler = async ({ url }) => {
const lat = url.searchParams.get('lat');
const lon = url.searchParams.get('lon');
try {
const lat = url.searchParams.get('lat');
const lon = url.searchParams.get('lon');

if (!lat || !lon) return new Response(undefined, { status: 418 });
if (!lat || !lon) return new Response(undefined, { status: 418 });

const component = MerchantOG.render({ lat, lon, STADIA_API_KEY });
const component = MerchantOG.render({ lat, lon, STADIA_API_KEY });

const image = await generateImage(component);
const image = await generateImage(component);

return new Response(image, {
headers: {
'content-type': 'image/png',
'cache-control': 'max-age=31449600'
}
});
return new Response(image, {
headers: {
'content-type': 'image/png',
'cache-control': 'max-age=31449600'
}
});
} catch (error) {
console.log(error);
return new Response(undefined, { status: 418 });
}
};

0 comments on commit bd7fe0f

Please sign in to comment.