You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+41-18
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Nosflare
2
2
3
-
Nosflare is a serverless [Nostr](https://github.com/fiatjaf/nostr) relay purpose-built for [Cloudflare Workers](https://workers.cloudflare.com/) and the[Cloudflare KV](https://www.cloudflare.com/products/workers-kv/) store.
3
+
Nosflare is a serverless [Nostr](https://github.com/fiatjaf/nostr) relay purpose-built for [Cloudflare Workers](https://workers.cloudflare.com/) and a[Cloudflare R2](https://www.cloudflare.com/developer-platform/r2/) bucket.
4
4
5
5
This relay is designed to be easy to deploy, scalable, and cost-effective, leveraging Cloudflare's edge computing infrastructure to provide a resilient relay for the Nostr decentralized social protocol.
6
6
@@ -20,7 +20,7 @@ Most applicable NIPs are supported along with support for allowlisting or blockl
20
20
21
21
### Dependencies
22
22
23
-
This project requires the [@noble/curves](https://github.com/paulmillr/noble-curves) package for cryptographic operations and esbuild:
23
+
This project requires the [@noble/curves](https://github.com/paulmillr/noble-curves) package for cryptographic operations and the [@evanw/esbuild](https://github.com/evanw/esbuild) bundler:
24
24
25
25
```
26
26
npm install @noble/curves
@@ -29,7 +29,7 @@ npm install -g esbuild
29
29
30
30
### Building
31
31
32
-
Clone the `worker.js`file to your machine. Edit the contents of `relayInfo` and `relayIcon` as desired to customize the relay name, icon, etc.
32
+
Clone the repo to your machine and open `worker.js`in a file editor. Edit the contents of `relayInfo` and `relayIcon` as desired to customize the relay name, icon, etc.
33
33
34
34
*Optional:*
35
35
- Edit the `nip05Users` section to add usernames and their hex pubkey for NIP-05 verified Nostr address.
@@ -52,29 +52,41 @@ The command assumes you're in the same directory as the `worker.js` file.
52
52
53
53
You can deploy Nosflare using either the Wrangler CLI, directly through the Cloudflare dashboard, or with the third-party deployment script:
54
54
55
-
#### Using Wrangler CLI
55
+
#### Cloudflare Dashboard
56
+
57
+
1. Log in to your Cloudflare dashboard.
58
+
2. Go to the Workers section and create a new worker. You can call it whatever you'd like.
59
+
3. Copy the contents of `dist/worker.js` and paste into the online editor. See the `example.js` file in this repo for what a successfully bundled file should look like.
60
+
4. Save and deploy the worker.
61
+
5. Add a custom domain in Worker's settings (this will be the desired relay URL).
62
+
6. Create a R2 bucket to store events. You can call it whatever you want.
63
+
7. In R2 bucket settings, add a custom subdomain (ex: nostr-events.site.com).
64
+
8. In the Worker's variables settings add the following environment variables: `customDomain` that will be the subdomain URL you set in bucket, `apiToken` this will be your cloudflare API token (recommended to set a custom API token that only has cache purge privileges), `zoneId` which is for the domain you're using for the R2 bucket (this ID can be found in the right sidebar of the overview page for the domain).
65
+
9. In a different section on the Settings > Variables page, bind the `relayDb` variable to the R2 bucket you created in the R2 Bucket Bindings section.
66
+
67
+
Examples:
68
+
69
+

70
+
71
+

72
+
73
+

74
+
75
+
#### Wrangler CLI
56
76
57
77
1. Configure your `wrangler.toml` with your Cloudflare account details.
58
78
2. Publish the worker:
59
79
60
80
```
61
81
wrangler publish
62
82
```
63
-
3. Add a custom domain (this will be the desired relay URL).
64
-
4. Create a KV namespace to store events. You can call it whatever you want.
65
-
5. Bind the `relayDb` variable to the KV namespace for the Worker in the Settings > Variables tab under the "KV Namespace Bindings" section.
83
+
3. Add a custom domain in Worker's settings (this will be the desired relay URL).
84
+
4. Create a R2 bucket to store events. You can call it whatever you want.
85
+
5. In R2 bucket settings, add a custom subdomain (ex: nostr-events.site.com).
86
+
6. In the Worker's variables settings add the following environment variables: `customDomain` that will be the subdomain URL you set in bucket, `apiToken` this will be your cloudflare API token (recommended to set a custom API token that only has cache purge privileges), `zoneId` which is for the domain you're using for the R2 bucket (this ID can be found in the right sidebar of the overview page for the domain).
87
+
7. In a different section on the Settings > Variables page, bind the `relayDb` variable to the R2 bucket you created in the R2 Bucket Bindings section.
66
88
67
-
#### Using Cloudflare Dashboard
68
-
69
-
1. Log in to your Cloudflare dashboard.
70
-
2. Go to the Workers section and create a new worker. You can call it whatever you'd like.
71
-
3. Copy the contents of `dist/worker.js` and paste into the online editor. See the `example.js` file in this repo for what a successfully bundled file should look like.
72
-
4. Save and deploy the worker.
73
-
5. Add a custom domain (this will be the desired relay URL).
74
-
6. Create a KV namespace to store events. You can call it whatever you want.
75
-
7. Bind the `relayDb` variable to the KV namespace for the Worker in the Settings > Variables tab under the "KV Namespace Bindings" section.
76
-
77
-
#### Using NosflareDeploy script
89
+
#### NosflareDeploy Script
78
90
79
91
A third-party script to easily deploy Nosflare. Read more [here](https://github.com/PastaGringo/NosflareDeploy).
80
92
@@ -92,11 +104,22 @@ Example:
92
104
93
105
The current release of Nosflare is primarily focused on [basic protocol flow](https://github.com/nostr-protocol/nips/blob/master/01.md) usage. This ensures events are stored and retrieved very quickly. However, the following is a non-exhaustive list of planned features:
94
106
107
+
- Event streaming
95
108
- "Pay-to-relay" (charging sats for access)
96
109
- Client authorization (NIP-42)
97
110
- File storage through Cloudflare R2 bucket (NIP-96)
98
111
- Encrypted DMs (NIP-44)
99
112
113
+
## Recommended Cloudflare Settings
114
+
115
+
Ensure optimal performance of the relay by enforcing a high cache rate and lengthy Cloudflare edge TTL as well as enabling rate limiting in order to protect the relay from abuse.
116
+
117
+
Examples:
118
+
119
+

120
+
121
+

122
+
100
123
## Contributing
101
124
102
125
Contributions to Nosflare are welcome! Please submit issues, feature requests, or pull requests through the project's [GitHub repository](https://github.com/Spl0itable/nosflare).
0 commit comments