feat(storage): complete phase 3 branding foundation

This commit is contained in:
poyrazavsever
2026-07-16 17:05:59 +03:00
parent b155132acf
commit 5d863280bf
31 changed files with 5302 additions and 57 deletions
+33
View File
@@ -0,0 +1,33 @@
import "server-only";
import { getSqliteConnection } from "../db/client";
import { BrandingService, DEFAULT_BRANDING, buildBrandingTokens, type PublicBranding } from "./service";
export function getBrandingService(): BrandingService {
return new BrandingService(getSqliteConnection().db);
}
export function getPublicBranding(): PublicBranding {
try {
return getBrandingService().getPublic();
} catch (error) {
if (isMissingBrandingTable(error)) {
return {
...DEFAULT_BRANDING,
lightLogoUrl: null,
darkLogoUrl: null,
iconUrl: null,
cssVariables: buildBrandingTokens(
DEFAULT_BRANDING.primaryColor,
DEFAULT_BRANDING.accentColor,
DEFAULT_BRANDING.radiusScale,
),
};
}
throw error;
}
}
function isMissingBrandingTable(error: unknown): boolean {
return error instanceof Error && error.message.includes("no such table: instance_branding");
}