refactor: extract image-helpers (#2261)

This commit is contained in:
Ted Liang
2025-12-09 09:19:49 +11:00
committed by GitHub
parent 3bd34964cd
commit c5032d0c43
12 changed files with 69 additions and 56 deletions
@@ -1,7 +1,6 @@
import sharp from 'sharp';
import { getTeamSettings } from '@documenso/lib/server-only/team/get-team-settings';
import { getFileServerSide } from '@documenso/lib/universal/upload/get-file.server';
import { loadLogo } from '@documenso/lib/utils/images/logo';
import type { Route } from './+types/branding.logo.team.$teamId';
@@ -56,16 +55,12 @@ export async function loader({ params }: Route.LoaderArgs) {
);
}
const img = await sharp(file)
.toFormat('png', {
quality: 80,
})
.toBuffer();
const { content, contentType } = await loadLogo(file);
return new Response(img, {
return new Response(content, {
headers: {
'Content-Type': 'image/png',
'Content-Length': img.length.toString(),
'Content-Type': contentType,
'Content-Length': content.length.toString(),
// Stale while revalidate for 1 hours to 24 hours
'Cache-Control': 'public, s-maxage=3600, stale-while-revalidate=86400',
},