···
import { setupServer } from "@/server";
const main = async () => {
17
-
let latticeUrlOrigin = decodeURIComponent(
18
-
SERVICE_DID.startsWith("did:web:") ? SERVICE_DID.slice(8) : "",
20
-
if (latticeUrlOrigin === "localhost")
21
-
latticeUrlOrigin += `:${SERVER_PORT.toString()}`;
22
-
if (latticeUrlOrigin === "") {
23
-
// TODO: resolve did:plc endpoint to get the origin of the lattice endpoint described by the did:plc doc
24
-
// for now we just throw.
26
-
"did:plc support not yet implemented. Provide a did:web for now. did:plc support will come in the future.",
30
-
const latticeAtUri: Required<AtUri> = {
31
-
// @ts-expect-error alas, template literal weirdness continues uwu
32
-
authority: OWNER_DID,
33
-
collection: "systems.gmstn.development.lattice",
34
-
rKey: latticeUrlOrigin,
37
-
const latticeRecord = await getRecordFromAtUri(latticeAtUri);
39
-
if (latticeRecord.ok) {
40
-
setRegistrationState(true);
43
-
const prismWebsocket = connectToPrism({
44
-
wantedCollections: ["systems.gmstn.development.*"],
47
-
// TODO: probably move this to an `attachListeners` hook that attaches the listeners we want.
48
-
attachLatticeRegistrationListener(prismWebsocket);
50
-
await performHandshakes(latticeAtUri);
const server = await setupServer();
for (const [url, route] of Object.entries(routes)) {
···
61
+
let latticeUrlOrigin = decodeURIComponent(
62
+
SERVICE_DID.startsWith("did:web:") ? SERVICE_DID.slice(8) : "",
64
+
if (latticeUrlOrigin === "localhost")
65
+
latticeUrlOrigin += `:${SERVER_PORT.toString()}`;
66
+
if (latticeUrlOrigin === "") {
67
+
// TODO: resolve did:plc endpoint to get the origin of the lattice endpoint described by the did:plc doc
68
+
// for now we just throw.
70
+
"did:plc support not yet implemented. Provide a did:web for now. did:plc support will come in the future.",
74
+
const latticeAtUri: Required<AtUri> = {
75
+
// @ts-expect-error alas, template literal weirdness continues uwu
76
+
authority: OWNER_DID,
77
+
collection: "systems.gmstn.development.lattice",
78
+
rKey: latticeUrlOrigin,
81
+
const latticeRecord = await getRecordFromAtUri(latticeAtUri);
83
+
if (latticeRecord.ok) {
84
+
setRegistrationState(true);
87
+
const prismWebsocket = connectToPrism({
88
+
wantedCollections: ["systems.gmstn.development.*"],
91
+
// TODO: probably move this to an `attachListeners` hook that attaches the listeners we want.
92
+
attachLatticeRegistrationListener(prismWebsocket);
94
+
await performHandshakes(latticeAtUri);