@ -17,16 +17,17 @@ A Nostr index relay built with Phoenix 1.8 / Elixir. Stores and serves Nostr eve
### Automated setup
### Automated setup
Run the setup script — it installs Erlang/Elixir via asdf, starts the Apache AGE database container, and runs `mix setup`:
Run the setup script — on Debian/Ubuntu it installs Erlang/Elixir from **Team RabbitMQ’s apt repositories** ([Elixir install guide](https://elixir-lang.org/install.html)); on Fedora/RHEL it uses **asdf**. It starts the Apache AGE database container and runs `mix setup`:
```bash
```bash
chmod +x setup.sh
chmod +x setup.sh
./setup.sh
./setup.sh
```
```
After setup, database credentials are written to `.env`. Source it before running any `mix` commands:
After setup, database credentials are written to `.env` (including `REQUIRE_DB=true` for integration tests). Source it before running `mix` tasks that need the DB or asdf’s `mix` in a new terminal:
```bash
```bash
source "$HOME/.asdf/asdf.sh" # if `mix` is not found
source .env
source .env
```
```
@ -53,6 +54,7 @@ export POSTGRES_PORT=5455
export POSTGRES_USER=postgres
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres
export POSTGRES_PASSWORD=postgres
export POSTGRES_DB=gc_index_relay_dev
export POSTGRES_DB=gc_index_relay_dev
export REQUIRE_DB=true
mix setup
mix setup
```
```
@ -60,24 +62,12 @@ mix setup
### Starting the server
### Starting the server
```bash
```bash
source "$HOME/.asdf/asdf.sh" # if needed
source .env
source .env
mix phx.server
mix phx.server
```
```
The relay is available at [http://localhost:4000](http://localhost:4000). After edits to `config/config.exs`, `config/dev.exs`, or `config/runtime.exs`, restart the server manually; other code is hot-reloaded.
The relay listens on port **4000** by default (see `PORT` in `config/runtime.exs`). Open [http://localhost:4000](http://localhost:4000). After edits to `config/config.exs`, `config/dev.exs`, or `config/runtime.exs`, restart the server manually; other code is hot-reloaded.
| `POST` | `/api/events/filter` | Query events with a NIP-01 filter body (`limit` required) |
| `GET` | `/api/events/:id` | Fetch a single event by ID |
| `POST` | `/api/events` | Publish a new event |
| `DELETE` | `/api/events/:id` | Delete an event by ID |
| `GET` | `/api/swagger` | Swagger UI |
| `GET` | `/health` | Health check |
### NIP-11 relay info
### NIP-11 relay info
@ -95,13 +85,15 @@ Unit tests (no database required):
mix test.unit
mix test.unit
```
```
Integration tests (requires the database to be running):
Integration tests (requires the database to be running). You must have `REQUIRE_DB=true` (included in `.env` from `setup.sh`) so the Repo starts under test:
```bash
```bash
source .env
source .env
mix test.integration
mix test.integration
```
```
Without `.env`: `REQUIRE_DB=true mix test.integration`
Run the full integration probe against the relay API (covers all endpoints, CORS, NIP-11, NIP-70):
Run the full integration probe against the relay API (covers all endpoints, CORS, NIP-11, NIP-70):