Backend (Express + Prisma, ES modules, as Accounts): /api/health and /api/v1/site/status (Coming soon until the first publish), the content model and its first migration, and the confirmed section variants per template (WEBSITE-1.0-PLAN §3, decision 16) with the template switch rules, with tests. Frontend (Next.js 16): Coming soon page, admin placeholder, robots.txt. env.template.json, PM2 example, CHANGELOG and WHATS-NEW. Root workspaces and lint updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
1.0 KiB
TypeScript
19 lines
1.0 KiB
TypeScript
/**
|
|
* What the public site shows right now: Coming soon until the first publish (§5, decision 3), then
|
|
* the latest published version. After the first publish there's no going back to Coming soon.
|
|
*/
|
|
import { WEBSITE_TEMPLATES, type WebsiteTemplate } from '@crosscode/contracts';
|
|
import type { Ctx } from '../context.js';
|
|
|
|
export type SiteStatus =
|
|
| { mode: 'coming-soon' }
|
|
| { mode: 'published'; version: number; publishedAt: string; template: WebsiteTemplate | null };
|
|
|
|
export async function siteStatus(ctx: Ctx): Promise<SiteStatus> {
|
|
const latest = await ctx.db.siteVersion.findFirst({ orderBy: { number: 'desc' }, select: { number: true, publishedAt: true, snapshot: true } });
|
|
if (!latest) return { mode: 'coming-soon' };
|
|
const t = (latest.snapshot as { design?: { template?: unknown } } | null)?.design?.template;
|
|
const template = (WEBSITE_TEMPLATES as readonly unknown[]).includes(t) ? (t as WebsiteTemplate) : null;
|
|
return { mode: 'published', version: latest.number, publishedAt: latest.publishedAt.toISOString(), template };
|
|
}
|