Next.js console for Cloudflare Workers (OpenNext config, wrangler.jsonc) with data in the console's own Scribase project, schema railyard (migration 0001: orgs, org_members, apps, deploys, entitlements, billing_events, api_tokens, device_codes; idempotent, RLS on, no anon grants). - Sign-in with Google or GitHub through Scribase Auth (PKCE), user read from the auth server, org and entitlements row created, signed HttpOnly session. - Money ladder (pure, immutable): $1 card check credited back to the customer wallet, 14-day trial with the plan's limits, $19 a month or $190 a year, pause switch and one-click cancel (ends at the next billing date; a trial ends now). - Webhook: Standard Webhooks signature and timestamp verified, replays ignored by unique message id, signed checkout metadata, other brands ignored, a refund of the card check reverses the credit and the trial, a failed wallet call releases the id for the provider's retry. - Apps, Usage and Billing screens, one primary action each; Add app shows the deploy command and the Insights tag in two clicks. - CLI device-flow login and org-scoped hashed tokens for Y-3. - Test mode only: the live payment host is refused unless the owner sets RAILYARD_DODO_LIVE=1. Tests (node --test, 25): journey from sign-in to entitlements and the snippet, refund, pause and cancel, webhook security, ladder, tokens and org isolation, PostgREST repo, a component test of Add app with the copy lint, a next build grep for sentinel secrets in the client bundle, and the migration applied twice on a scratch Postgres. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
1.0 KiB
TypeScript
25 lines
1.0 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { currentSession } from "../../lib/current.ts";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export default async function DevicePage({ searchParams }: { searchParams: { code?: string; approved?: string; error?: string } }) {
|
|
if (!(await currentSession())) redirect("/");
|
|
return (
|
|
<main className="center">
|
|
<section className="card" style={{ width: 420 }}>
|
|
<h1>Connect the Railyard CLI</h1>
|
|
{searchParams.approved ? (
|
|
<p>Done. Go back to your terminal.</p>
|
|
) : (
|
|
<form method="post" action="/api/device/approve" className="row">
|
|
<input type="text" name="code" defaultValue={searchParams.code ?? ""} placeholder="ABCD-EFGH" aria-label="Code from your terminal" required />
|
|
<button className="primary" type="submit">Connect</button>
|
|
</form>
|
|
)}
|
|
{searchParams.error ? <p className="error">That code is not valid any more. Run railyard login again.</p> : null}
|
|
</section>
|
|
</main>
|
|
);
|
|
}
|