~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

The built console hands the host's methods on, as vite dev does

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:web/forward
harness/e2e/flows.spec.mjs+8−0
@@ -33,6 +33,14 @@ test('seeing her groups', async () => {
await expect(page.locator('.group-row', { hasText: 'Riders' }).first()).toBeVisible()
})
test('coming back to her groups by a link, the page drawn in the browser', async () => {
await page.goto(url('/new'))
await page.getByRole('link', { name: 'opensocial' }).click()
await page.waitForURL(url('/'))
await expect(page.getByRole('heading', { name: 'Your groups' })).toBeVisible()
await expect(page.locator('.group-row', { hasText: 'Riders' }).first()).toBeVisible()
})
test('starting a group', async () => {
await page.getByRole('link', { name: 'Start a group' }).click()
await page.getByRole('textbox', { name: 'Handle' }).fill('hikers.groups.test')
web/src/routes/+page.ts+6−11
@@ -6,18 +6,13 @@ import { xrpc } from '#lib/data.ts';
/**
* The groups of whoever is signed in and those inviting them, and every
* group this host runs. A
* host that does not answer yet, as while its methods are being brought
* over, is drawn as one with none.
* group this host runs. A host that fails to answer fails the page, rather
* than be drawn as one with none.
*/
export const load: PageLoad = async (event) => {
const { viewer } = await event.parent();
const all = await xrpc<typeof listGroups.main>(event, 'fyi.opensocial.listGroups', {}).catch(() => null);
const mine = viewer
? await xrpc<typeof getActorGroups.main>(event, 'fyi.opensocial.getActorGroups', { actor: viewer.did }).catch(() => null)
: null;
const invited = viewer
? await xrpc<typeof getActorInvites.main>(event, 'fyi.opensocial.getActorInvites', {}).catch(() => null)
: null;
return { groups: all?.groups ?? [], mine: mine?.groups ?? null, invitations: invited?.invites ?? [] };
const all = await xrpc<typeof listGroups.main>(event, 'fyi.opensocial.listGroups', {});
const mine = viewer ? await xrpc<typeof getActorGroups.main>(event, 'fyi.opensocial.getActorGroups', { actor: viewer.did }) : null;
const invited = viewer ? await xrpc<typeof getActorInvites.main>(event, 'fyi.opensocial.getActorInvites', {}) : null;
return { groups: all.groups, mine: mine?.groups ?? null, invitations: invited?.invites ?? [] };
};
web/src/hooks.server.ts+8−4
@@ -2,12 +2,16 @@ import type { Handle, HandleFetch } from '@sveltejs/kit/hooks';
import { GROUP_HOST } from '$app/env/private';
/**
* Signing in and out is the group host's (`/console/*`): asked of this
* site, it is asked of the host, cookies and all, and its answer, its
* redirects and the cookies it sets among it, is the browser's.
* What is the group host's, asked of this site, is asked of the host,
* cookies and all, and its answer, its redirects and the cookies it sets
* among it, is the browser's: signing in and out (`/console/*`), and its
* methods and OAuth, which a page asks from the browser once it is there,
* as `vite dev` hands them on.
*/
const HOSTS = ['/console/', '/xrpc/', '/oauth/', '/.well-known/'];
export const handle: Handle = async ({ event, resolve }) => {
if (!event.url.pathname.startsWith('/console/')) return resolve(event);
if (!HOSTS.some((p) => event.url.pathname.startsWith(p))) return resolve(event);
const asked = new Request(`${GROUP_HOST}${event.url.pathname}${event.url.search}`, {
method: event.request.method,
headers: event.request.headers,