tangled
alpha
login
or
join now
graham.systems
/
silhouette
0
fork
atom
Resolve your Bluesky avatar with a human URL
silhouette.town
atproto
deno
0
fork
atom
overview
issues
pulls
pipelines
serve help text at root route
graham.systems
1 month ago
c5db16b6
0ee8a6e8
verified
This commit was signed with the committer's
known signature
.
graham.systems
SSH Key Fingerprint:
SHA256:j2sN/ABe7mfw8RwswfUi4owiaZYA2sTKCSkKlqYb35M=
+33
1 changed file
expand all
collapse all
unified
split
main.ts
+33
main.ts
···
4
4
import { isActorIdentifier } from "@atcute/lexicons/syntax";
5
5
import { AppBskyActorProfile } from "@atcute/bluesky";
6
6
7
7
+
const ROOT = new URLPattern({ pathname: "/" });
7
8
const IDENTIFIER_ROUTE = new URLPattern({ pathname: "/avatar/:identifier" });
8
9
const slingshot = new Client({
9
10
handler: simpleFetchHandler({ service: "https://slingshot.microcosm.blue" }),
10
11
});
11
12
13
13
+
function generateSpiel(origin: string) {
14
14
+
return `<h1>
15
15
+
silhouette
16
16
+
</h1>
17
17
+
18
18
+
<p>
19
19
+
Quickly get the URL to your Bluesky profile photo using an identifier (handle or DID). Go to:
20
20
+
</p>
21
21
+
22
22
+
<p>
23
23
+
<code>${origin}/avatar/<your-identifier></code>
24
24
+
</p>
25
25
+
26
26
+
<p>
27
27
+
For example:
28
28
+
<a href="${origin}/avatar/graham.systems">
29
29
+
${origin}/avatar/graham.systems
30
30
+
</a>
31
31
+
</p>`;
32
32
+
}
33
33
+
12
34
// Algorithm:
13
35
// 1. Resolve minidoc from identifier in URL
14
36
// 2. Resolve Bluesky actor profile from PDS
15
37
// 3. Return 303 with profile picture blob URL
16
38
17
39
export async function handler(req: Request): Promise<Response> {
40
40
+
if (ROOT.exec(req.url)) {
41
41
+
const url = new URL(req.url);
42
42
+
return new Response(generateSpiel(url.origin), {
43
43
+
status: STATUS_CODE.OK,
44
44
+
statusText: STATUS_TEXT[STATUS_CODE.OK],
45
45
+
headers: {
46
46
+
"Content-Type": "text/html",
47
47
+
},
48
48
+
});
49
49
+
}
50
50
+
18
51
const match = IDENTIFIER_ROUTE.exec(req.url);
19
52
20
53
if (!match) {