crosscode: scripts/products/website.sh (ports 5300/3300, uploads in the export), crosscode add <church> website (needs Accounts; www.<address> or the Cross Code address), one install_app for Accounts and the Website, env template copy, bats tests. Backend: Hub client (protocol v2, product website), crosscode.link/1 with automatic connect to the church's Accounts, sign-in through @crosscode/auth-client with the Website's own session and roles, the first Owner from HUB_ADMIN_EMAIL (verified), 2FA for Owners and Admins, back-channel logout, Accounts' user.* calls, and the church export. Frontend: admin sign-in/out and the sign-in problem page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
/**
|
|
* Everything a request handler or job needs, passed in rather than imported, so tests can run the
|
|
* whole app against an in-memory database and a stand-in Accounts (tests/support/).
|
|
*/
|
|
import type { PrismaClient } from './generated/prisma/client.js';
|
|
import type { Config } from './lib/config.js';
|
|
import { Secrets } from './lib/crypto.js';
|
|
import { Settings } from './lib/settings.js';
|
|
import { loadAuthClient, type AuthClientModule } from './auth/accounts.js';
|
|
|
|
export type Db = PrismaClient;
|
|
|
|
export type Ctx = {
|
|
config: Config;
|
|
db: Db;
|
|
secrets: Secrets;
|
|
settings: Settings;
|
|
/** `@crosscode/auth-client` (tests give a stand-in). */
|
|
authClient: () => Promise<AuthClientModule>;
|
|
now: () => Date;
|
|
};
|
|
|
|
export function createCtx(config: Config, db: Db, opts: { now?: () => Date; authClient?: () => Promise<AuthClientModule> } = {}): Ctx {
|
|
const secrets = new Secrets(config.secret);
|
|
const partial = { config, db, secrets } as Ctx;
|
|
partial.settings = new Settings(partial);
|
|
partial.authClient = opts.authClient ?? loadAuthClient;
|
|
partial.now = opts.now ?? (() => new Date());
|
|
return partial;
|
|
}
|