This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
// Every HTTP entry point of this app but the sign-in redirects: /api/health, /api/ready,
|
||||
// /api/openapi.json and /api/v1/<procedure>. One file, because there is one mount (spec §6.2).
|
||||
|
||||
import { handle } from "../../../src/server/router"
|
||||
|
||||
// A procedure call reads a session and a database; nothing here may be cached or prerendered.
|
||||
export const dynamic = "force-dynamic"
|
||||
export const runtime = "nodejs"
|
||||
|
||||
export const GET = handle
|
||||
export const POST = handle
|
||||
// A procedure whose payload is a byte stream (kit-core .stream(field)) is answered on PUT.
|
||||
export const PUT = handle
|
||||
@@ -0,0 +1,19 @@
|
||||
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
// /api/auth/*: the same-origin route from this app's pages to Better Auth on its Convex deployment
|
||||
// (AUTH_PROVIDER=convex-better-auth). Only the endpoints a sign-in, sign-up, sign-out, password
|
||||
// change, device revocation or account deletion needs are forwarded, and no bearer comes back
|
||||
// (@conusai-kit/auth-convex-better-auth's proxy). A deployment that selected another provider has no
|
||||
// such route.
|
||||
import { loadAuthConfig } from "@conusai-kit/auth"
|
||||
import { betterAuthRuntime } from "../../../../src/server/app"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
export const runtime = "nodejs"
|
||||
|
||||
async function handle(request: Request): Promise<Response> {
|
||||
if (loadAuthConfig().provider !== "convex-better-auth") return new Response(null, { status: 404 })
|
||||
return betterAuthRuntime().proxy(request)
|
||||
}
|
||||
|
||||
export const GET = handle
|
||||
export const POST = handle
|
||||
@@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
// The app's own share image (Open Graph and Twitter card, spec §10.1): the app brand's name and logo in
|
||||
// the brandbook's treatment, 1200x630. It is public, because a link preview is fetched without a session,
|
||||
// and it carries nothing of any organization. The image only changes when the brand file does, so it is
|
||||
// drawn once per process.
|
||||
|
||||
import { appBrand } from "@app/config"
|
||||
import { renderShareImage, shareBrand } from "@app/modules/branding"
|
||||
import { appIdentity, appOnlyReaders } from "../../../../src/server/brand-assets"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
let drawn: Promise<Buffer<ArrayBuffer>> | undefined
|
||||
|
||||
export async function GET(): Promise<Response> {
|
||||
try {
|
||||
drawn ??= (async () => {
|
||||
const share = await shareBrand({ app: appIdentity(), tenant: null, readers: appOnlyReaders() })
|
||||
return Buffer.from(await renderShareImage(share, { title: appBrand.name }))
|
||||
})()
|
||||
return new Response(await drawn, {
|
||||
headers: {
|
||||
"content-type": "image/png",
|
||||
"x-content-type-options": "nosniff",
|
||||
"cache-control": "public, max-age=3600",
|
||||
},
|
||||
})
|
||||
} catch {
|
||||
drawn = undefined
|
||||
return new Response(null, { status: 500 })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user