app: the House of Prayer's backend (APP-1.0-PLAN §3)

Commitments stored as rules (start, length, once/daily/weekly, end, skips) in the
church's timezone, daylight saving included; the day's coverage as counts only,
cached until a booking changes, live over server-sent events (X-Accel-Buffering
off, a comment every 25 s). Booking, skipping, changing, cancelling within the
8-hour rule, renewing (a signed single-use link), "I prayed" (self-reported).
Campaigns and moderated testimonies; the admin's bookings with names, always
access-logged; booking on a member's behalf. Reminders (every minute) and
renewal notices (14 and 3 days before) queued in an outbox for the messaging
slice. The heartbeat's prayer counts; export and delete for a member's prayer.
Migration 20261202000000_house_of_prayer (checked on PostgreSQL 18: applies, no
diff). 66 backend tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 10:29:39 +02:00
co-authored by Claude Opus 5.5
parent 6726518175
commit 5213bb36c0
23 changed files with 2376 additions and 30 deletions
+16
View File
@@ -113,3 +113,19 @@ export function cookiesFrom(res: { headers: Record<string, unknown> }, keep: Rec
}
export const cookieHeader = (c: Record<string, string>) => Object.entries(c).map(([k, v]) => `${k}=${v}`).join('; ');
/**
* Signs `who` in through the stand-in Accounts (with 2FA when `mfa`), creating them as a Member
* with `roles` first if given; answers the cookies to send.
*/
export async function signInAs(h: Harness, who: { sub: string; name?: string; email?: string; roles?: string[] }, mfa = false): Promise<Record<string, string>> {
const { default: request } = await import('supertest');
if (who.roles?.length) {
await h.db.member.upsert({ where: { id: who.sub }, create: { id: who.sub, name: who.name ?? 'Someone', email: who.email ?? `${who.sub}@hope.test`, roles: who.roles }, update: { roles: who.roles } });
}
h.fake.next = { sub: who.sub, name: who.name ?? 'Someone', email: who.email ?? `${who.sub.slice(0, 8)}@hope.test`, amr: mfa ? ['pwd', 'mfa'] : ['pwd'] };
const start = await request(h.app).get(`/api/auth/signin?returnTo=%2F${mfa ? '&mfa=1' : ''}`);
const after = cookiesFrom(start);
const back = await request(h.app).get('/api/auth/callback?code=abc&state=xyz').set('Cookie', cookieHeader(after));
return cookiesFrom(back, after);
}