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:
Alireza Hassani
2026-08-26 00:51:11 +03:30
co-authored by Cursor
parent 6ce6f959ac
commit ead16080b8
13 changed files with 318 additions and 13 deletions
+12
View File
@@ -0,0 +1,12 @@
import { Controller, Get, Param } from '@nestjs/common';
import { WebsiteFaviconService } from './website-favicon.service';
@Controller('tenants/:host/website/favicon')
export class PublicWebsiteFaviconController {
constructor(private readonly service: WebsiteFaviconService) {}
@Get()
get(@Param('host') host: string) {
return this.service.getPublic(host);
}
}
+40
View File
@@ -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,
};
}
}
+4
View File
@@ -16,6 +16,8 @@ import {
PublicWebsiteBusinessInfoController,
} from './website-business-info.controller';
import { WebsiteBusinessInfoService } from './website-business-info.service';
import { PublicWebsiteFaviconController } from './website-favicon.controller';
import { WebsiteFaviconService } from './website-favicon.service';
import {
PublicWebsiteSlidersController,
WebsiteSlidersController,
@@ -39,6 +41,7 @@ import { WebsiteStaticImagesService } from './website-static-images.service';
PublicWebsiteStaticImagesController,
WebsiteStaticImagesController,
PublicWebsiteBusinessInfoController,
PublicWebsiteFaviconController,
],
providers: [
WebsiteCategoryGroupsService,
@@ -46,6 +49,7 @@ import { WebsiteStaticImagesService } from './website-static-images.service';
WebsiteSlidersService,
WebsiteStaticImagesService,
WebsiteBusinessInfoService,
WebsiteFaviconService,
],
})
export class WebsiteModule {}