Conversation
|
di we also have the docker scrip to run this? |
yess the dockerfile is there, but i will take a look into the file once to see if anything else needs to be added/modified |
does the preview need to hit the indexer? I am not sure it needs because we fetch only metadata from relays. |
|
caching can be very long IMO because it is not a lot of data, we should cash for weeks perhaps? |
| } | ||
|
|
||
| /** Sanitize a string for safe injection into HTML attribute values */ | ||
| function escapeHtml(str) { |
There was a problem hiding this comment.
are there not methods that do that already? why implement that yourself?
| } catch (error) { | ||
| console.error("Error fetching Nostr metadata:", error); | ||
| // Relays used for fetching Nostr data (events + profiles) | ||
| const NOSTR_RELAYS = (process.env.NOSTR_RELAYS || "wss://relay.angor.io,wss://purplepag.es").split(","); |
There was a problem hiding this comment.
purplepag is a special relay that is only used to fetch an npubs profile data like what relays my npub posts to.
This should not be use to fetch metadata.
There was a problem hiding this comment.
maybe just use relay.angor.io and relay2.angor.io
|
I only see a docker file we ned also a docker compose, so a user just needs to hit So the docker compose file will build the dockerfile and deploy |
Summary
from the server. Uses Node 22's built-in WebSocket to open short-lived connections to relays, fetch the
event/profile, and close.
subsequent requests serve in ~1ms.
injection into HTML attributes.
Working
Bot requests (Twitterbot, facebookexternalhit, etc.) get HTML with injected OG tags:
Indexer API → Nostr event (via WebSocket to relay.angor.io) → Profile (kind 0) → inject og:title, og:description,
og:image, og:url
Normal users get the unmodified Angular SPA.
Test plan
Outputs
Output -
The next time you do, it will come almost instantly due to caching, the first time it will take almost 30-40 seconds.
More needs to be checked on this PR after meging into main and deploying on docker
@dangershony