Skip to content

Commit b41864e

Browse files
authored
Merge pull request #1005 from carhartlewis/lewis/comp-trust-portal-tweaks
feat: add logo existence check to API endpoint for cached websites
2 parents bfbbcdb + 87bd99f commit b41864e

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

apps/trust/src/app/api/get-sites/route.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ const getCachedSites = cache(async () => {
2323
},
2424
});
2525

26-
return websites.map((website) => website.website);
26+
const logoUrls = websites
27+
.map((website) => website.website)
28+
.filter((website): website is string => Boolean(website))
29+
.map((website) => {
30+
const domain = website.replace(/^https?:\/\//, '').replace(/^www\./, '');
31+
return `https://img.logo.dev/${domain}?token=pk_QtKMUKc7QOKZmbzLG3Q8NQ&retina=true`;
32+
});
33+
34+
return logoUrls;
2735
});
2836

2937
export async function GET(request: NextRequest) {
3038
try {
3139
const websites = await getCachedSites();
3240

33-
console.log(websites);
34-
3541
const response = NextResponse.json(websites);
3642

3743
response.headers.set('Cache-Control', 'public, s-maxage=3600, stale-while-revalidate=86400');

0 commit comments

Comments
 (0)