Add website favicon API and manual favicon profile updates.
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>
This commit is contained in:
co-authored by
Cursor
parent
6ce6f959ac
commit
ead16080b8
@@ -0,0 +1,40 @@
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user