ac22ccef9b
Lands the minimum surface so a developer can: cd platform/orca-platform && make dev-up cd platform/tenant-registry && make dev cd platform/portal && make install && make dev open http://acme.localhost:3000 and complete a real OIDC sign-in against the breakpilot-dev realm. Layout: src/middleware.ts host→slug URL rewrite; backstage carve-out src/auth.ts Auth.js v5 Keycloak provider; passes tenant_id/slug/org_roles/products/plan/status claims through to the session src/app/api/auth/[...nextauth]/ Auth.js handlers (GET, POST) src/app/layout.tsx root html shell src/app/page.tsx apex landing src/app/[slug]/layout.tsx fetches tenant via lib/tenant-registry src/app/[slug]/page.tsx redirect to /dashboard src/app/[slug]/dashboard/page.tsx signed-out → Sign in with Keycloak signed-in → welcome + Sign out src/lib/host.ts testable host parser (apex/tenant/backstage) src/lib/tenant-registry.ts fetch client for the Go service Tooling: vitest 13 tests, 100% coverage of src/lib/ Next.js 15 build compiles all routes; output: standalone ESLint flat config next/core-web-vitals + next/typescript Real RBAC enforcement, the rest of the customer-area surfaces, and the backstage shell land per the M5.2 / M10.1 schedule. This is just enough to be the first thing a developer codes in. Refs: M5.1 (skeleton)
30 lines
974 B
TypeScript
30 lines
974 B
TypeScript
// Tenant Registry client — fetches tenant data from the Go service.
|
|
// Skeleton-mode: read-only by-slug lookup. The portal middleware uses this
|
|
// to resolve `<slug>.localhost:3000` → tenant context before rendering.
|
|
|
|
export type Tenant = {
|
|
id: string;
|
|
slug: string;
|
|
name: string;
|
|
status: "active" | "trial" | "frozen" | "archived" | "demo";
|
|
plan: "starter" | "professional" | "enterprise";
|
|
products: string[];
|
|
created_at: string;
|
|
};
|
|
|
|
function baseUrl(): string {
|
|
return process.env.TENANT_REGISTRY_URL ?? "http://localhost:8080";
|
|
}
|
|
|
|
export async function fetchTenantBySlug(slug: string): Promise<Tenant | null> {
|
|
const res = await fetch(`${baseUrl()}/v1/tenants/by-slug/${encodeURIComponent(slug)}`, {
|
|
headers: { accept: "application/json" },
|
|
cache: "no-store",
|
|
});
|
|
if (res.status === 404) return null;
|
|
if (!res.ok) {
|
|
throw new Error(`tenant-registry: ${res.status} ${res.statusText}`);
|
|
}
|
|
return (await res.json()) as Tenant;
|
|
}
|