Skip to content

Commit 93e3d6c

Browse files
authored
Merge branch 'main' into feature/261-NIP-05-verification
2 parents baabf8e + 1410824 commit 93e3d6c

51 files changed

Lines changed: 6783 additions & 13819 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# --- REQUIRED ---
2+
SECRET=change_me_to_something_long_and_random # Generate: openssl rand -hex 128
3+
4+
# --- POSTGRESQL ---
5+
DB_HOST=localhost
6+
DB_PORT=5432
7+
DB_NAME=nostr_ts_relay
8+
DB_USER=nostr_ts_relay
9+
DB_PASSWORD=nostr_ts_relay
10+
# Alternatively, use a URI:
11+
# DB_URI=postgresql://nostr_ts_relay:nostr_ts_relay@localhost:5432/nostr_ts_relay
12+
13+
# --- DB POOL TUNING (Optional) ---
14+
# DB_MIN_POOL_SIZE=0
15+
# DB_MAX_POOL_SIZE=3
16+
# DB_ACQUIRE_CONNECTION_TIMEOUT=60000
17+
18+
# --- REDIS (Required for Rate Limiting) ---
19+
REDIS_HOST=localhost
20+
REDIS_PORT=6379
21+
# REDIS_USER=default
22+
# REDIS_PASSWORD=
23+
# Alternatively, use a URI:
24+
# REDIS_URI=redis://localhost:6379
25+
26+
# --- SERVER CONFIG ---
27+
RELAY_PORT=8008
28+
WORKER_COUNT=2 # Defaults to CPU count. Use 1 or 2 for local testing.
29+
# NOSTR_CONFIG_DIR=.nostr # Where settings.yaml lives
30+
31+
# --- DEBUGGING ---
32+
# Useful namespaces: maintenance-worker, database-client:*, cache-client, etc.
33+
# DEBUG=maintenance-worker
34+
35+
# --- RELAY PRIVATE KEY (Optional) ---
36+
# RELAY_PRIVATE_KEY=your_hex_private_key
37+
38+
# --- PAYMENTS (Only if enabled in settings.yaml) ---
39+
# ZEBEDEE_API_KEY=
40+
# NODELESS_API_KEY=
41+
# NODELESS_WEBHOOK_SECRET=
42+
# OPENNODE_API_KEY=
43+
# LNBITS_API_KEY=
44+
45+
# --- READ REPLICAS (Optional) ---
46+
# READ_REPLICA_ENABLED=false
47+
# READ_REPLICAS=2
48+
# RR0_DB_HOST=localhost
49+
# RR0_DB_PORT=5432
50+
# RR0_DB_NAME=nostr_ts_relay
51+
# RR0_DB_USER=your_psql_username
52+
# RR0_DB_PASSWORD=your_psql_password
53+
# RR0_DB_MIN_POOL_SIZE=0
54+
# RR0_DB_MAX_POOL_SIZE=3
55+
# RR0_DB_ACQUIRE_CONNECTION_TIMEOUT=60000
56+
# RR1_DB_HOST=localhost
57+
# RR1_DB_PORT=5432
58+
# RR1_DB_NAME=nostr_ts_relay
59+
# RR1_DB_USER=your_psql_username
60+
# RR1_DB_PASSWORD=your_psql_password
61+
# RR1_DB_MIN_POOL_SIZE=0
62+
# RR1_DB_MAX_POOL_SIZE=3
63+
# RR1_DB_ACQUIRE_CONNECTION_TIMEOUT=60000
64+
65+
# --- TOR (Optional) ---
66+
# TOR_HOST=localhost
67+
# TOR_CONTROL_PORT=9051
68+
# TOR_PASSWORD=
69+
# HIDDEN_SERVICE_PORT=80

.github/workflows/checks.yml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
run: npm ci
4343
- name: Run ESLint
4444
run: npm run lint
45+
- name: Run Knip
46+
run: npm run knip
4547
build-check:
4648
name: Build check
4749
runs-on: ubuntu-latest
@@ -129,24 +131,6 @@ jobs:
129131
with:
130132
name: integration-coverage-lcov
131133
path: .coverage/integration/lcov.info
132-
sonarcloud:
133-
name: Sonarcloud
134-
needs: [test-units-and-cover, test-integrations-and-cover]
135-
runs-on: ubuntu-latest
136-
steps:
137-
- name: Checkout
138-
uses: actions/checkout@v3
139-
with:
140-
fetch-depth: 0
141-
- uses: actions/download-artifact@v4
142-
name: Download unit & integration coverage reports
143-
with:
144-
path: .coverage
145-
- name: SonarCloud Scan
146-
uses: sonarsource/sonarcloud-github-action@master
147-
env:
148-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
150134
post-tests:
151135
name: Post Tests
152136
needs: [test-units-and-cover, test-integrations-and-cover]

.knip.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@2/schema.json",
3+
"entry": [
4+
"src/index.ts",
5+
"src/import-events.ts",
6+
"knexfile.js"
7+
],
8+
"project": [
9+
"src/**/*.ts"
10+
],
11+
"ignoreFiles": [],
12+
"commitlint": false,
13+
"eslint": false,
14+
"github-actions": false,
15+
"husky": false,
16+
"mocha": false,
17+
"nyc": false,
18+
"semantic-release": false
19+
}

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.8.0
1+
v24.14.1

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ before making a change.
66

77
Please keep the conversations civil, respectful and focus on the topic being discussed.
88

9+
## Local Quality Checks
10+
11+
Run dead code and dependency analysis before opening a pull request:
12+
13+
```
14+
npm run knip
15+
```
16+
17+
`npm run lint` now runs Knip first, then ESLint.
18+
919
## Pull Request Process
1020

1121
1. Update the relevant documentation with details of changes to the interface, this includes new environment

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18-alpine3.16 AS build
1+
FROM node:24-alpine AS build
22

33
WORKDIR /build
44

@@ -10,7 +10,7 @@ COPY . .
1010

1111
RUN npm run build
1212

13-
FROM node:18-alpine3.16
13+
FROM node:24-alpine
1414

1515
LABEL org.opencontainers.image.title="Nostream"
1616
LABEL org.opencontainers.image.source=https://github.com/cameri/nostream

Dockerfile.railwayapp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Author Saransh Sharma @cynsar foundation
2-
FROM node:18-alpine3.16 as build
2+
FROM node:24-alpine as build
33

44
ARG PORT
55
ARG PGHOST
@@ -29,7 +29,7 @@ COPY . .
2929

3030
RUN npm run build
3131

32-
FROM node:18-alpine3.16
32+
FROM node:24-alpine
3333

3434
ARG PORT
3535
ARG PGHOST

Dockerfile.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18-alpine3.16
1+
FROM node:24-alpine
22

33
WORKDIR /code
44

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ NIPs with a relay-specific implementation are listed here.
6767
### Standalone setup
6868
- PostgreSQL 14.0
6969
- Redis
70-
- Node v18
70+
- Node v24
7171
- Typescript
7272

7373
### Docker setups
@@ -209,6 +209,10 @@ Start:
209209
```
210210
./scripts/start_with_tor
211211
```
212+
or, with Nginx reverse proxy and Let's Encrypt SSL:
213+
```
214+
RELAY_DOMAIN=relay.example.com CERTBOT_EMAIL=you@example.com ./scripts/start_with_nginx
215+
```
212216
213217
**Windows / WSL2 users:** Docker bind-mounts can cause PostgreSQL permission errors on Windows. Use the dedicated override file instead:
214218
```
@@ -230,6 +234,29 @@ Print the Tor hostname:
230234
./scripts/print_tor_hostname
231235
```
232236
237+
### Importing events from JSON Lines
238+
239+
You can import NIP-01 events from a `.jsonl` file directly into the relay database.
240+
241+
Basic import:
242+
```
243+
npm run import -- ./events.jsonl
244+
```
245+
246+
Set a custom batch size (default: `1000`):
247+
```
248+
npm run import -- ./events.jsonl --batch-size 500
249+
```
250+
251+
The importer:
252+
253+
- Processes the file line-by-line to keep memory usage bounded.
254+
- Validates NIP-01 schema, event id hash, and Schnorr signature before insertion.
255+
- Inserts in database transactions per batch.
256+
- Skips duplicates without failing the whole import.
257+
- Prints progress in the format:
258+
`[Processed: 50,000 | Inserted: 45,000 | Skipped: 5,000 | Errors: 0]`
259+
233260
### Running as a Service
234261
235262
By default this server will run continuously until you stop it with Ctrl+C or until the system restarts.

docker-compose.nginx.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
services:
2+
nginx:
3+
image: nginx:1.25-alpine
4+
container_name: nostream-nginx
5+
ports:
6+
- 80:80
7+
- 443:443
8+
volumes:
9+
- ${PWD}/nginx/conf.d:/etc/nginx/conf.d
10+
- ${PWD}/nginx/ssl:/etc/nginx/ssl
11+
- certbot-webroot:/var/www/certbot
12+
depends_on:
13+
- nostream
14+
restart: on-failure
15+
# Run nginx in foreground (so container exits if nginx dies).
16+
# A background loop watches for a signal file created by certbot
17+
# after cert issuance/renewal, and reloads nginx within seconds.
18+
command: >
19+
/bin/sh -c "while :; do
20+
if [ -f /etc/nginx/ssl/reload-nginx ]; then
21+
if nginx -t && nginx -s reload; then
22+
rm -f /etc/nginx/ssl/reload-nginx;
23+
fi;
24+
fi;
25+
sleep 5;
26+
done & nginx -g 'daemon off;'"
27+
networks:
28+
default:
29+
30+
certbot:
31+
image: certbot/certbot:v2.11.0
32+
container_name: nostream-certbot
33+
environment:
34+
RELAY_DOMAIN: ${RELAY_DOMAIN:?RELAY_DOMAIN required}
35+
CERTBOT_EMAIL: ${CERTBOT_EMAIL:?CERTBOT_EMAIL required}
36+
volumes:
37+
- ${PWD}/nginx/ssl:/etc/letsencrypt
38+
- ${PWD}/scripts/certbot_entrypoint.sh:/entrypoint.sh:ro
39+
- certbot-webroot:/var/www/certbot
40+
entrypoint: /entrypoint.sh
41+
depends_on:
42+
- nginx
43+
restart: on-failure
44+
networks:
45+
default:
46+
47+
volumes:
48+
certbot-webroot:

0 commit comments

Comments
 (0)