Expose GET /tenants/{domain}/website/favicon for storefront tab icons, allow faviconMediaId on profile PATCH, and sync website API docs.
Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
import { PrismaService } from '../prisma/prisma.service';
|
|
import { TenantService } from '../tenant/tenant.service';
|
|
|
|
@Injectable()
|
|
export class WebsiteFaviconService {
|
|
constructor(
|
|
private readonly prisma: PrismaService,
|
|
private readonly tenant: TenantService,
|
|
) {}
|
|
|
|
async getPublic(host: string) {
|
|
const business = await this.tenant.resolveBusinessByDomain(host);
|
|
|
|
const record = await this.prisma.business.findUnique({
|
|
where: { id: business.id },
|
|
select: {
|
|
faviconMediaId: true,
|
|
logoMedia: { select: { publicUrl: true } },
|
|
logoDarkMedia: { select: { publicUrl: true } },
|
|
faviconMedia: { select: { publicUrl: true } },
|
|
},
|
|
});
|
|
|
|
if (!record) {
|
|
throw new NotFoundException('Business not found');
|
|
}
|
|
|
|
const logoUrl = record.logoMedia?.publicUrl ?? null;
|
|
const logoDarkUrl = record.logoDarkMedia?.publicUrl ?? null;
|
|
const faviconUrl = record.faviconMedia?.publicUrl ?? logoUrl;
|
|
|
|
return {
|
|
faviconUrl,
|
|
logoUrl,
|
|
logoDarkUrl,
|
|
hasDedicatedFavicon: record.faviconMediaId != null,
|
|
};
|
|
}
|
|
}
|