Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ logs
*.log
npm-debug.log*

# Linter
.lint-reports/

# Coverage
.nyc_output
.test-reports
Expand All @@ -17,8 +20,10 @@ node_modules/
# Optional npm cache directory
.npm

# Optional eslint cache
# Caches
.eslintcache
.dccache
.DS_Store

# generate output
dist
Expand Down
6 changes: 6 additions & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ Running `nostr-ts-relay` for the first time creates the settings file in `~/.nos
| limits.event.pubkey.blacklist | List of public keys to reject. Public keys in this list will not be able to post to this relay. |
| limits.event.createdAt.maxPositiveDelta | Maximum number of seconds an event's `created_at` can be in the future. Defaults to 900 (15 minutes). Disabled when set to zero. |
| limits.event.createdAt.minNegativeDelta | Maximum number of secodns an event's `created_at` can be in the past. Defaults to zero. Disabled when set to zero. |
| limits.event.rateLimits[].kinds | List of event kinds rate limited. Use `[min, max]` for ranges. Optional. |
| limits.event.rateLimits[].period | Rate limiting period in milliseconds. |
| limits.event.rateLimits[].rate | Maximum number of events during period. |
| limits.client.subscription.maxSubscriptions | Maximum number of subscriptions per connected client. Defaults to 10. Disabled when set to zero. |
| limits.client.subscription.maxFilters | Maximum number of filters per subscription. Defaults to 10. Disabled when set to zero. |
| limits.message.rateLimits[].period | Rate limit period in milliseconds. |
| limits.message.rateLimits[].rate | Maximum number of messages during period. |
| limits.message.ipWhitelist | List of IPs (IPv4 or IPv6) without rate limit. |
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,25 @@ NIPs with a relay-specific implementation are listed here.
- [x] NIP-13: Proof of Work
- [x] NIP-15: End of Stored Events Notice
- [x] NIP-16: Event Treatment
- [x] NIP-20: Command Results
- [x] NIP-22: Event `created_at` Limits
- [x] NIP-26: Delegated Event Signing
- [x] NIP-33: Parameterized Replaceable Events

## Requirements

- PostgreSQL 15.0 (For standalone steps only)
### Standalone setup
- PostgreSQL 15.0
- Redis
- Node v18
- Typescript
- Docker (For docker steps only, version 20 or higher)

## Quick Start (Docker Compose) (Best)
### Docker setups
- Node v18
- Docker v20.10
- Docker compose v2.10

## Quick Start (Docker Compose)

Install Docker following the [official guide](https://docs.docker.com/engine/install/).
You may have to uninstall Docker if you installed it using a different guide.
Expand All @@ -75,7 +82,7 @@ Clone repository and enter directory:

Start with:
```
npm run docker:compose:start &
npm run docker:compose:start -- --detach
```

Stop the server with:
Expand All @@ -84,6 +91,7 @@ Stop the server with:
```

## Quick Start (over Tor)
`Docker` `Tor`

Install Docker following the [official guide](https://docs.docker.com/engine/install/).
You may have to uninstall Docker if you installed it using a different guide.
Expand All @@ -96,7 +104,7 @@ Clone repository and enter directory:

Start with:
```
npm run tor:docker:compose:start &
npm run tor:docker:compose:start
```

Print the Tor hostname:
Expand All @@ -119,6 +127,10 @@ Set the following environment variables:
DB_NAME=nostr_ts_relay
DB_USER=postgres
DB_PASSWORD=postgres
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_USER=default
REDIS_PASSWORD=nostr_ts_relay
```

Create `nostr_ts_relay` database:
Expand All @@ -129,6 +141,15 @@ Create `nostr_ts_relay` database:
postgres=# quit
```

Start Redis and use `redis-cli` to set the default password and verify:
```
$ redis-cli
127.0.0.1:6379> CONFIG SET requirepass "nostr_ts_relay"
OK
127.0.0.1:6379> AUTH nostr_ts_relay
Ok
```

Clone repository and enter directory:
```
git clone git@github.com:Cameri/nostr-ts-relay.git
Expand Down
27 changes: 25 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@ services:
build: .
container_name: nostr-ts-relay
environment:
PORT: 8008
NOSTR_CONFIG_DIR: /home/node/
DB_HOST: db
DB_PORT: 5432
DB_USER: nostr_ts_relay
DB_PASSWORD: nostr_ts_relay
DB_NAME: nostr_ts_relay
DB_MIN_POOL_SIZE: 2
DB_MAX_POOL_SIZE: 10
NOSTR_CONFIG_DIR: /home/node/
PORT: 8008
REDIS_HOST: cache
REDIS_PORT: 6379
REDIS_USER: default
REDIS_PASSWORD: nostr_ts_relay
DEBUG: "worker:*"
user: node:node
volumes:
- $HOME/.nostr:/home/node/
ports:
- 8008:8008
depends_on:
cache:
condition: service_healthy
db:
condition: service_healthy
migrations:
Expand All @@ -43,6 +50,21 @@ services:
interval: 5s
timeout: 5s
retries: 5
cache:
image: redis:7.0.5-alpine3.16
container_name: cache
volumes:
- cache:/data
command: redis-server --save 20 1 --loglevel warning --requirepass nostr_ts_relay
networks:
default:
ipv4_address: 10.10.10.4
restart: always
healthcheck:
test: [ "CMD", "redis-cli", "ping", "|", "grep", "PONG" ]
interval: 1s
timeout: 5s
retries: 5
migrations:
image: node:18-alpine3.16
container_name: migrations
Expand Down Expand Up @@ -75,3 +97,4 @@ networks:

volumes:
pgdata:
cache:
Loading