mirror of
https://github.com/hanzoai/sign.git
synced 2026-11-02 23:26:15 +00:00
The resource API is /v1/rest and the operation API is /v1/rpc: named for what they are, so neither shadows the other, and the v2-beta alias is gone. Hanzo IAM returns to /auth/callback, the callback path IAM already derives for this host, so sign-in needs no IAM change. Claude-Session: https://claude.ai/code/session_01TUxvfuta1Z44KVNYuAz71F
69 lines
1.6 KiB
TypeScript
69 lines
1.6 KiB
TypeScript
import { getTeamSettings } from '@hanzo/esign-lib/server-only/team/get-team-settings';
|
|
import { getFileServerSide } from '@hanzo/esign-lib/universal/upload/get-file.server';
|
|
import { loadLogo } from '@hanzo/esign-lib/utils/images/logo';
|
|
|
|
import type { Route } from './+types/branding.logo.team.$teamId';
|
|
|
|
export async function loader({ params }: Route.LoaderArgs) {
|
|
const teamId = Number(params.teamId);
|
|
|
|
if (teamId === 0 || Number.isNaN(teamId)) {
|
|
return Response.json(
|
|
{
|
|
status: 'error',
|
|
message: 'Invalid team ID',
|
|
},
|
|
{ status: 400 },
|
|
);
|
|
}
|
|
|
|
const settings = await getTeamSettings({
|
|
teamId,
|
|
});
|
|
|
|
if (!settings || !settings.brandingLogo) {
|
|
return Response.json(
|
|
{
|
|
status: 'error',
|
|
message: 'Logo not found',
|
|
},
|
|
{ status: 404 },
|
|
);
|
|
}
|
|
|
|
if (!settings.brandingEnabled) {
|
|
return Response.json(
|
|
{
|
|
status: 'error',
|
|
message: 'Branding is not enabled',
|
|
},
|
|
{ status: 400 },
|
|
);
|
|
}
|
|
|
|
const file = await getFileServerSide(JSON.parse(settings.brandingLogo)).catch((e) => {
|
|
console.error(e);
|
|
});
|
|
|
|
if (!file) {
|
|
return Response.json(
|
|
{
|
|
status: 'error',
|
|
message: 'Not found',
|
|
},
|
|
{ status: 404 },
|
|
);
|
|
}
|
|
|
|
const { content, contentType } = await loadLogo(file);
|
|
|
|
return new Response(content as unknown as BodyInit, {
|
|
headers: {
|
|
'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',
|
|
},
|
|
});
|
|
}
|