A relay run at cloudflare.
- NIP-01 (Basic protocol flow description)
- NIP-02 (Follow List)
- NIP-05 (Mapping Nostr keys to DNS-based internet identifiers)
- NIP-09 (Event Deletion)
- NIP-11 (Relay Information Document)
- NIP-12 (Generic Tag Queries)
- NIP-33 (Parameterized Replaceable Events)
- NIP-42 (Authentication of clients to relays)
- NIP-45 (Counting results)
- NIP-50 (Search Capability)
- NIP-95 (Shared File)
- NIP-96 (HTTP File Storage Integration)
- NIP-98 (HTTP Auth)
| Function | Cloudflare implement |
|---|---|
| Event Store | D1 |
| File Store (NIP-95) | KV |
| File Store (NIP-96) | R2 |
Why do we use the KV to save the file store?
Because the R2 must bing the payment method and when it run out of the free plan limit, it would make some fee.
Change OWNER TO Your plain Pubkey.
Change NIP05_USERS_TEXT for your NIP05. (Optional)
create d1 database
wrangler d1 create relayrun init script
wrangler d1 execute relay --file=init.sqlwrangler kv:namespace create relayIf you want to use R2, you must config your payment to cloudflare. I can't ensure that it won't cost you money
After config payment, you can init the R2 bucket now. You can do it in the cloudflare website or run this script:
wrangler r2 bucket create relayIt is important that config a custom domain for your bucket. Due to this domain can user cloudflare's cache and it will save you money.
You can readmore from this Connect a bucket to a custom domain .
change the owners in in wrangler.toml, chenge the 29320975df855fe34a7b45ada2421e2c741c37c0136901fe477133a91eb18b07 to you plain owner id.
OWNER = "29320975df855fe34a7b45ada2421e2c741c37c0136901fe477133a91eb18b07"(Optional). change the nip05 config
// nip05 user config should set like this:
NIP05_USERS_TEXT = '{"dashu": "29320975df855fe34a7b45ada2421e2c741c37c0136901fe477133a91eb18b07"}'(Optional). If you use R2 for NIP-96 and had config a custom domain, you should config r2CustomDomain in wrangler.toml.
R2_CUSTOM_DOMAIN = "You custom domain like: https://xxxxxx.com ";change config file wrangler.toml set the database_id and kv_namespaces' id
[[d1_databases]]
binding = "DB"
database_name = "relay"
database_id = "Here is there d1 id"
[[kv_namespaces]]
binding = "KV"
id = "Here is there kv id"(Optional). If you use R2 for NIP-96, you should also add this setting to wrangler.toml.
[[d1_databases]]
[[r2_buckets]]
binding = "R2"
bucket_name = "You bucket name"run this script to install project dependent
npm installrun this script to deploy
npm run deploy