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>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
/**
|
|
* The link endpoints siblings call (`crosscode.link/1`): Accounts (or Events) connecting to and
|
|
* disconnecting from this site. Errors use the link protocol's `{ code, message }`.
|
|
*/
|
|
import express from 'express';
|
|
import { LINK_PATHS } from '@crosscode/contracts';
|
|
import type { Ctx } from '../context.js';
|
|
import { acceptConnect, acceptDisconnect, LinkError } from './connect.js';
|
|
|
|
export function linksRouter(ctx: Ctx) {
|
|
const r = express.Router();
|
|
const json = express.json({ limit: '32kb' });
|
|
const fail = (res: express.Response, e: unknown) => {
|
|
if (e instanceof LinkError) return res.status(e.status).json({ code: e.code, message: e.message });
|
|
console.error('[links]', e);
|
|
return res.status(500).json({ code: 'INTERNAL', message: 'Something went wrong.' });
|
|
};
|
|
r.post(LINK_PATHS.connect.replace(/^\/api/, ''), json, async (req, res) => {
|
|
try {
|
|
res.json(await acceptConnect(ctx, req.body, req));
|
|
} catch (e) {
|
|
fail(res, e);
|
|
}
|
|
});
|
|
r.post(LINK_PATHS.disconnect.replace(/^\/api/, ''), json, async (req, res) => {
|
|
try {
|
|
await acceptDisconnect(ctx, req.body, req);
|
|
res.json({ ok: true });
|
|
} catch (e) {
|
|
fail(res, e);
|
|
}
|
|
});
|
|
return r;
|
|
}
|