tangled
alpha
login
or
join now
vielle.dev
/
atcities.dev
8
fork
atom
[WIP] A (somewhat barebones) atproto app for creating custom sites without hosting!
8
fork
atom
overview
issues
pulls
pipelines
server: handle route in seperate function
vielle.dev
5 months ago
29ed1201
bff1235e
+11
-8
1 changed file
expand all
collapse all
unified
split
src
user.ts
+11
-8
src/user.ts
···
23
23
web: new WebDidDocumentResolver(),
24
24
},
25
25
});
26
26
+
async function getRoute(
27
27
+
did: `did:${"plc" | "web"}:${string}`,
28
28
+
pds: string,
29
29
+
route: string
30
30
+
): Promise<Response> {
31
31
+
return new Response("404 NOT FOUND: " + route, {
32
32
+
status: 404,
33
33
+
});
34
34
+
}
26
35
27
36
export default async function (
28
28
-
_req: Request,
37
37
+
req: Request,
29
38
user:
30
39
| { handle: `${string}.${string}` }
31
40
| { did: `did:plc:${string}` | `did:web:${string}` }
···
71
80
}
72
81
);
73
82
74
74
-
pds;
75
75
-
76
76
-
return new Response(`Resolved: ${"handle" in user ? user.handle : user.did}
77
77
-
78
78
-
handle: ${"handle" in user ? user.handle : (doc.alsoKnownAs?.filter((x) => x.startsWith("at://"))[0] ?? "N/A")}
79
79
-
did: ${did}
80
80
-
pds: ${pds}`);
83
83
+
return await getRoute(did, pds, new URL(req.url).pathname);
81
84
}