ConusAI vendor v0.1.0-dev.20261027+9b1131fb
ci / gate (push) Waiting to run

This commit is contained in:
ConusAI vendor v0.1.0-dev.20261027+9b1131fb
2026-10-27 18:05:17 +00:00
commit 3102273ec7
538 changed files with 80203 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
// An organization's share image (spec §10.3): its display name and its logo for the dark page (its own, or
// the one it has when it has only one, or the app brand's), in the brandbook's treatment, 1200x630.
//
// It goes through the same caller as every page, so only a member of the organization draws it, and a
// non-member and a missing organization get the same 404. The logo is checked by the kit's rules wherever
// it comes from; one that cannot be drawn is replaced by the app brand's, and the image is still served.
import { appBrand } from "@app/config"
import { brandGet, renderShareImage, shareBrand } from "@app/modules/branding"
import { AppError } from "@conusai-kit/core"
import { orgGet } from "@conusai-kit/tenancy"
import { appIdentity, readersFor } from "../../../../src/server/brand-assets"
import { pageContext } from "../../../../src/server/page"
export const dynamic = "force-dynamic"
export async function GET(_request: Request, { params }: { params: Promise<{ org: string }> }): Promise<Response> {
const { org } = await params
try {
const { caller } = await pageContext()
const organization = await caller.call(orgGet, { org })
const brand = await caller.call(brandGet, { org })
const share = await shareBrand({
app: appIdentity(),
tenant: { name: organization.name, brand },
readers: readersFor(caller, org),
})
const png = await renderShareImage(share, { title: share.name, footer: appBrand.name })
return new Response(Buffer.from(png), {
headers: {
"content-type": "image/png",
"x-content-type-options": "nosniff",
"cache-control": "private, max-age=300",
},
})
} catch (error) {
// A non-member, a missing organization and a logo nobody can draw are not told apart.
return new Response(null, { status: error instanceof AppError && error.status < 500 ? 404 : 500 })
}
}